HTML Headings
HTML Headings
Headings are defined by the <h1> to <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>
Note: Browsers automatically add space before and after headings.
The Importance of Headings
Make sure to use HTML heading tags only for headings. Do not use headings merely to create bold or large text.
Search engines use headings to index the structure and content of your web pages.
Headings are important for presenting the document structure because users can quickly navigate through your web page using headings.
You should use <h1> for the main heading (most important), followed by <h2> (secondary importance), and then <h3>, and so on.
Note: <h1> is not mandatory for a page but is recommended for the main title of an article. Each page should have only one <h1>. The number of <h2>-<h6> tags is unlimited.
HTML Horizontal Lines
The <hr> tag creates a horizontal line in an HTML page.
The <hr> element is 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>
HTML Comments
Comments can be inserted into HTML code to increase readability and make the code easier to understand. Browsers will ignore comments and will not display them.
Example:
<!-- This is a comment -->
Note: After the opening bracket (left angle bracket), an exclamation mark ! (English punctuation) is required. No punctuation is needed before the closing bracket (right angle bracket). Using comments properly can help with future code editing.
HTML Tip - How to View Source Code
Have you ever looked at a webpage and wondered how it was created?
If you want to find out the secrets, just right-click and select "View Source" (IE) or "View Page Source" (Firefox). Other browsers have similar options. This will open a window containing the page's HTML code.
HTML Tag Reference Manual
Our site's tag reference manual provides more information about these headings and their attributes.
You will learn more about HTML tags and attributes in the following sections of this tutorial.
Tag | Description |
---|---|
<html> | Defines an HTML document |
<body> | Defines the body of the document |
<h1>- <h6> | Defines HTML headings |
<hr> | Defines a horizontal line |
<!--...--> | Defines a comment |