X

Headline

This is an important message requiring you to make a choice if you're based in the EU.

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.

Syntax

The <h1>-<h6> tags come in pairs, so the closing tag is required.

As the <h1> to <h6> tags are block-level elements, they always start on a new line and take up the full width available.

Example

<!DOCTYPE html>
<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>

Result

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.

As the align attribute is not supported in HTML5, use the CSS font-size and font-weight properties instead.

Attributes

Attribute Value Description
align left
right
center
justify
Defines the vertical alignment of the tag content.
Not supported in HTML 5.

The <h1> to <h6> tags support the Global Attributes and the Event Attributes.


Browser support



Do you find this helpful?

Related articles