6. HTML Headings
What you will learn
- The six heading levels
- Why headings are about structure, not size
- Good heading practice for people and search engines
The six heading levels
HTML has six heading elements, from <h1> (most important) to <h6> (least important).
Example
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Output (shown as styled text on this page)
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
By default, browsers show <h1> as the biggest and <h6> as the smallest.
Headings describe structure
Think of headings as the outline of a document. The <h1> is the title. The <h2> elements are the main sections. An <h3> is a subsection inside an <h2>, and so on.
Example: a simple outline
<h1>Healthy Eating</h1>
<h2>Fruit</h2>
<h3>Apples</h3>
<h3>Oranges</h3>
<h2>Vegetables</h2>
Why headings matter
- Screen reader users jump between headings to scan a page.
- Search engines use headings to understand what a page is about.
- Every reader finds long pages easier to scan.
Good practice
- Use one
<h1>per page, describing the main topic. - Do not skip levels. Go from
<h2>to<h3>, not<h2>to<h5>. - Do not choose a heading level just because of its size. Change size with CSS instead.
- Do not use headings to make ordinary text bold.
You can resize any heading with CSS. Choose the level by meaning, then style it to look the way you want.
Common mistakes
- Using several
<h1>elements for visual effect. - Skipping heading levels.
- Using a heading when you only want large or bold text.
- Forgetting the closing tag, such as
<h2>Title</h3>.
Exercise
Write the outline for a page called My Hobbies with two sections, Music and Sports.
Show solution
<h1>My Hobbies</h1>
<h2>Music</h2>
<h2>Sports</h2>
Knowledge check
1. How many heading levels does HTML have?
Six, from <h1> to <h6>.
2. How many <h1> elements should a page normally have?
One.
3. Should you pick a heading level to make text smaller?
No. Choose it for structure and use CSS for size.
Summary
- Headings run from
<h1>to<h6>. - They build the outline of your page.
- Use one
<h1>, do not skip levels, and style with CSS.
Next lesson: HTML Paragraphs.