HTML <h1>-<h6> Tags
The <h1> to <h6> elements are used to define six levels of HTML Headings, with <h1> being the highest (or most important) level and <h6> the least important one.
Each web page must have only one <h1> heading. As search engines use it to index the structure and content of web documents, be sure to include keywords in it.
User agents may use heading information for automatically creating a content table for a document.
If you want to resize text, it’s better not to use heading tags. You can use the CSS font-size property instead. It’s recommended not to skip heading levels ( <h1>, <h2> and so on) and to use <h1> only once on a page.
Headline tags have SEO value as well. A search engine tries to find out two things about your page: what the page is about, and how good it is. One of the main things that search engines look at for determining a page content is the words inside heading tags.
When a page has a single piece of content, its main title must be in <h1> tag, the larger sections must be included in <h2> and so on. In this way, you can make your content more organized. You should remember that no one reads every word of content.
There are two types of pages with content: single content pages and index pages. On single content pages, the title of that piece of content must be in <h1> near the top of <body>. On an index page, the site title or the index name is usually put in <h1>. Then the titles of all the listed individual parts must have <h2>.
As the <h1> to <h6> tags are block-level elements, they always start on a new line and take up the full width available.
The <h1>-<h6> tags come in pairs, so the closing tag is required.
Example of the HTML <h1>-<h6> tags:
<html> <head> <title>Title of the document</title> </head> <body> <h1>First-level heading</h1> <h2>Second-level heading</h2> <h3>Third-level heading</h3> <h4>Fourth-level heading</h4> <h5>Fifth-level heading</h5> <h6>Sixth-level heading</h6> </body> </html>
The <h1>-<h6> elements must not be used to markup subheadings, subtitles, alternative titles, and taglines unless intended to be the heading for a new section or subsection.
|Defines the vertical alignment of the tag content.
Not supported in HTML 5.
How to style <h1>-<h6> tag?
Common properties to alter the visual weight/emphasis/size of text in <h1>-<h6> tag:
- CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit.
- CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.
- CSS font-size property sets the size of the font.
- CSS font-weight property defines whether the font should be bold or thick.
- CSS text-transform property controls text case and capitalization.
- CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.
Coloring text in <h1>-<h6> tag:
- CSS color property describes the color of the text content and text decorations.
- CSS background-color property sets the background color of an element.
Text layout styles for <h1>-<h6> tag:
- CSS text-indent property specifies the indentation of the first line in a text block.
- CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user.
- CSS white-space property specifies how white-space inside an element is handled.
- CSS word-break property specifies where the lines should be broken.
Other properties worth looking at for <h1>-<h6> tag:
- CSS text-shadow property adds shadow to text.
- CSS text-align-last property sets the alignment of the last line of the text.
- CSS line-height property specifies the height of a line.
- CSS letter-spacing property defines the spaces between letters/characters in a text.
- CSS word-spacing property sets the spacing between words.