Description

The HTML element <h1> to <h6> are used to define headings.

There are six heading elements <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>.

  • The <h1> element is the most important heading and displays bigger than others
  • The <h6> element is the least important heading and displays smaller than others

Here are some suggestions while using headings on a web page.

  • Always define only one <h1> element to define the page heading, which is helpful for SEO
  • Always use headings sequentially on a page like <h1> for the main heading, <h2> for its sub-heading, <h3> for the next level sub-heading, and so on.

The below table summarizes its usage.

Usage Details
Placement It is displayed as a Block element.
Contents It can contain Inline elements and text.
Tags Both opening and closing tags are required.
Versions HTML 2,3.2, 4, 4.01, 5

Syntax

Here is the basic syntax of the <h1> to <h6> elements.

<h1>...</h1>
<h2>...</h2>
<h3>...</h3>
<h4>...</h4>
<h5>...</h5>
<h6>...</h6>

Examples

Element <hgroup> used to define web page header with navigation links.

<h1>Heading level 1</h1>
<h2>Heading level 2</h2>
<h3>Heading level 3</h3>
<h4>Heading level 4</h4>
<h5>Heading level 5</h5>
<h6>Heading level 6</h6>

Attributes

The following table shows the list of supported and unsupported attributes for the heading elements.

Attribute Type Details
Element-Specific Attributes The tags <h1> to <h6> doesn't have any element-specific attributes.
Global Attributes Like all other HTML tags, the tags <h1> to <h6> supports the HTML Global Attributes.
Event Attributes The tags <h1> to <h6> also supports the HTML Event Attributes.

Here is a list of attributes that are specific to the heading elements.

Attribute Value Description
align left, right, center, justify Obsolete and Not to be used.
Aligns the content inside a heading element.

Browser Compatibility

The tags <h1> to <h6> are supported in all modern browsers.

  • Google Chrome 1+
  • Internet Explorer or Edge 2+
  • Firefox 1+
  • Apple Safari 1+
  • Opera 4+

Related Links