TExcelTAD
Home › HTML › HTML Headings

HTML Headings

Headings give a page its outline. Just like chapter and section titles in a book, they tell readers — and search engines and screen readers — how the content is organised.

Six levels

HTML has six heading elements, from <h1> (most important) to <h6> (least important).

html · try it yourself
<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>

Browsers display higher-level headings larger and bolder, and add some space above and below each one automatically.

Headings describe structure, not size

Choose a heading level by its place in the outline, not by how big you want the text to look. You can always change the size with CSS later.

html · try it yourself
<h1>Travel Guide: Lisbon</h1>

<h2>Where to stay</h2>
<h3>Alfama</h3>
<p>Narrow streets and views of the river.</p>
<h3>Baixa</h3>
<p>Central, flat and close to everything.</p>

<h2>What to eat</h2>
<h3>Pastel de nata</h3>
<p>A custard tart you should try at least once.</p>

Read the headings on their own and you get a table of contents:

Travel Guide: Lisbon
  Where to stay
    Alfama
    Baixa
  What to eat
    Pastel de nata

That is exactly what screen readers offer: many users jump from heading to heading to scan a page, the same way sighted users skim bold titles.

Rules of thumb

Guideline Why
Use one <h1> per page for the main title It clearly states what the page is about
Don't skip levels (e.g. <h2> straight to <h4>) Skipping confuses the outline for assistive technology
Never use headings just to make text bold or big Use <strong> or CSS instead
Keep headings short and descriptive They act as signposts

Note: Search engines give extra weight to words in headings when working out what a page is about. Clear headings help people find your page.

Changing heading size

If a heading's default size doesn't fit your design, change it with the style attribute (or, better, a stylesheet) — keep the correct level.

html · try it yourself
<h1 style="font-size: 22px; color: #e34c26;">A small but important title</h1>
<h2 style="font-size: 40px; font-weight: 300;">A large, light subtitle</h2>
<p>Each heading keeps its meaning, only the look has changed.</p>

Horizontal rules between sections

The <hr> element marks a thematic break — a change of topic. It is often used between sections and is drawn as a line by default.

html · try it yourself
<h2>Part one</h2>
<p>The story begins on a rainy Tuesday.</p>
<hr>
<h2>Part two</h2>
<p>Three weeks later, the sun came out.</p>

The head is not a heading

Beginners sometimes mix up <head> and the heading elements. They are completely different:

  • <head> is the invisible information section at the top of the document.
  • <h1>–<h6> are visible headings inside the <body>.

Tip: Before writing a long page, sketch its heading outline first. If the outline reads well on its own, the page will be easy to navigate.

Test yourself

Which heading element is the most important?

  1. <h6>
  2. <head>
  3. <h1>
  4. <heading>

You want large text that is not a section title. What should you use?

  1. <h1>
  2. CSS on a normal element such as <p>
  3. <h6> with a big font
  4. <head>

Why is skipping from <h2> straight to <h5> discouraged?

  1. It is a syntax error
  2. It breaks the logical outline used by screen readers
  3. Browsers refuse to render <h5>
  4. It makes the page load slower