HTML Heading Elements: Understanding h1 to h6 with Examples

html heading elements

The heading elements define a content structure in HTML. Use <h1> to <h6> to show levels. <h1> means the main heading. While the <h6> means the lowest subheading.

The search engines read them to find topic levels, and users scan them to find key ideas.

Understand the HTML Headings

Heading elements appear bold and large in HTML. Browsers apply default styles. Use only one <h1> on each page and lower level to break content into parts.

Search engines use headings to understand the page. <h1> shows the main topic. Include the keyword in it. While the lower headings group related points. That helps crawlers scan faster. A clear structure helps index each section.

Do not skip levels. That confuses the parsers. Write tags in order to show clear relationships.

Here is the syntax:

<h1>Main Title</h1>
<h2>Subsection</h2>
<h3>Detail under subsection</h3>

You write it like this to avoid nested errors. Use proper tags from top to bottom.

Use CSS for visual changes and don’t use heading elements to make bold text in HTML.

Here is the right use case:

  • Use only one <h1> tag.
  • Place it before other content.
  • Define the topic clearly.
  • Follow the order from <h1> to <h6>.
  • Do not jump levels. Keep the structure flat and readable.
  • Keep text short.
  • Use words that match the section.
  • Do not add style to the tag.

Use CSS for spaces and fonts. Use headings to show topic flow.

Headings are semantic. They show structure and use it to mark sections. While paragraphs hold text and they do not define a level. Use them to write content.

The div element groups items. Use them with classes. So, only headings affect SEO and show the content structure.

Here is the accessibility of headings:

  • Screen readers follow heading order.
  • They use it to skip or scan.
  • Correct use supports users with low vision.
  • It gives clear document flow.
  • Use the order from <h1> to <h6> with no gaps.
  • Do not jump levels.
  • Add aria-level if the content uses generated HTML.

Styles of HTML Headings Tags with CSS

Style headings with CSS. Do not change HTML for style only. Use selectors to apply font or size.

Here is an example:

h2 {
  font-size: 1.5rem;
  color: #333;
}

Apply the same pattern to each level. This keeps the design consistent. Use IDs or classes for custom cases.

Examples of HTML Headings in HTML

Basic Heading Structure:

<article>
  <h1>Article Title</h1>
  <section>
    <h1>Section Title</h1>
  </section>
</article>

It’s valid to use multiple <h1> tags within different semantic containers like <article> or <section>. Each represents the top heading within its own scope.

Multiple <h1> Tags in HTML5:

<div class="heading-style">My Custom Heading</div>

Here, a <div> is styled with CSS to look like a heading. While this affects appearance, it doesn’t provide semantic meaning like <h1>–<h6> do (which matters for SEO and accessibility).

Styles of Non-Heading Elements:

<div class="heading-style">My Custom Heading</div>

Here, a <div> is styled with CSS to look like a heading. While this affects appearance, it doesn’t provide semantic meaning like <h1>–<h6> do (which matters for SEO and accessibility).

Skip Heading Levels (Not Recommended):

<h1>Main Title</h1>
<h4>Too Small Subsection</h4>

Jump heading levels (like from <h1> to <h4>) is technically allowed but discouraged. It can confuse users and screen readers. Always try to follow a logical order (e.g., <h2> after <h1>).

Wrapping Up

In this article, you learned what HTML heading tags do and how they define structure.

Here is a quick recap:

  • Use <h1> to <h6> to create a content hierarchy.
  • Apply only one <h1> tag per page.
  • Follow the order of levels with no skips.
  • Don’t use headings for styles.
  • Style headings with CSS only.
  • Use semantic structure to improve SEO and readability.
  • Help assistive technologies with correct heading flow.

What are HTML heading tags?

HTML heading tags (<h1> to <h6>) are used to define headings on a webpage. They represent different levels of importance, where <h1> is the most important and <h6> is the least.

How many HTML heading tags are there?

There are six heading tags in HTML: <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>.

Can I use more than one tag per page?

Yes, HTML5 allows using multiple <h1> tags, especially when you use semantic elements like <section> or <article>.

Can I create custom headings like or ?

You can style other elements (like <div>) with CSS to look like headings.

How should I order heading tags?

Use heading tags in a hierarchical structure:
  • <h1> for the main title
  • <h2> for major sections
  • <h3> for subsections under <h2>, and so on.

Do heading tags help with SEO?

Yes, search engines use heading tags to understand the structure and key topics of a page.

Similar Reads

HTML Header Tag: The Complete Guide with Examples

The header tag defines the top part of a page or a section in HTML. It usually holds a heading…

HTML Form Tag: How Create User Input Forms

The HTML form tag helps you collect user input on a website. You use the HTML form tag to create…

HTML Breadcrumb Navigation Guide for Beginners

The breadcrumb in HTML shows a path through a site and marks the place of a page inside it. It…

HTML Boolean Attributes with Examples

HTML Boolean attributes control the behavior of elements and do not need a value. These attributes simplify logic and reduce…

HTML del Tag: How to Mark Deleted Text in Pages

The HTML del tag shows text that a user or author removed from a page. A browser shows this text…

How to Build Responsive HTML Email Templates

Email templates are still the key tools for work and brands in HTML. A simple email can reach many people,…

The Button Tag in HTML: How it Works with Examples

The HTML button tag creates interactive controls on a web page. You can use this element to trigger actions or…

HTML details Tag: How to Toggle Hidden Content

The <details> tag hides content and shows it when needed. It helps organize long pages. The tag shows extra info…

HTML time Tag: Representing Dates and Times

The HTML time Tag marks time values in a document. Use it to show dates or times that machines and…

HTML dir Attribute: How to Set Text Direction

The dir attribute tells the browser which way text should go in HTML. You use it when a page or…

Previous Article

The Img Tag in HTML: How to Display Images

Next Article

HTML Form Tag: How Create User Input Forms

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *


Subscribe to Get Updates

Get the latest updates on Coding, Database, and Algorithms straight to your inbox.
No spam. Unsubscribe anytime.