HTML Titles

In an HTML document, titles are important.

HTML Titles

Headings (Heading) are defined by the <h1> - <h6> tags.

<h1> Defines the largest heading. <h6> Defines the smallest heading.

Example

<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>

Try It Yourself

Note:Browsers automatically add blank lines before and after headings.

Note:By default, HTML automatically adds an extra blank line before and after block-level elements, such as paragraphs and title elements.

Titles are important

Make sure to use HTML heading tags only for titles. Do not use headings just to produce bold or large text.

Search engines use titles to index the structure and content of your web page.

Since users can quickly browse your web page through titles, it is important to present the document structure with titles.

The h1 should be used as the main title (the most important), followed by h2 (the next most important), then h3, and so on.

HTML Horizontal Line

<hr /> tag creates a horizontal line in an HTML page.

The hr element can be used to separate content.

Example

<p>This is a paragraph</p>
<hr />
<p>This is a paragraph</p>
<hr />
<p>This is a paragraph</p>

Try It Yourself

Tip:Using horizontal lines (the <hr> tag) to separate sections of an article is one way (but not the only way).

HTML Comments

Comments can be inserted into HTML code to improve readability and make the code easier to understand. Browsers will ignore comments and not display them.

Comments are written as follows:

Example

<!-- This is a comment -->

Try It Yourself

Note:After the beginning parenthesis (the left parenthesis), a感叹号 is needed to follow closely, and there is no need for an exclamation mark before the end parenthesis (the right parenthesis).

Tip:Using comments reasonably can help future code editing work.

HTML Tip - How to View Source Code

You must have been amazed when you saw a web page and exclaimed, 'WOW! How is this done?'

If you want to find the secrets, just click the right mouse button and select 'View Source File' (IE) or 'View Page Source Code' (Firefox), and the same for other browsers. This will open a window containing the HTML code of the page.

Examples from This Page

Titles
How to Display Titles in an HTML Document.
Hidden Comments
How to Insert Comments in HTML Source Code.
Horizontal Line
How to Insert a Horizontal Line.

HTML Tag Reference Manual

The CodeW3C.com Tag Reference Manual provides more information about these headings and their properties.

You will learn more about HTML tags and attributes in the following chapters of this tutorial.

Tag Description
<html> Define the HTML Document.
<body> Define the Body of the Document.
<h1> to <h6> Define HTML Headings
<hr> Define Horizontal Line.
<!--...--> Define Comments.