HTML Headings
HTML headings are the six elements <h1> to <h6> that mark the titles and subtitles of a page. They create an outline of the content, a bit like chapter and section titles in a book, and that outline is used by readers scanning the page, by screen readers, and by search engines trying to understand what each part is about.
The six levels and what they mean
<h1> is the most important heading and <h6> the least. The number shows rank in the outline, not size. Browsers do display lower numbers larger by default, but that is just a starting style that CSS can change.
<h1>Indian Street Food Guide</h1>
<h2>North India</h2>
<h3>Chole Bhature</h3>
<p>Spicy chickpeas served with fried bread...</p>
<h3>Aloo Tikki</h3>
<p>Crisp potato patties topped with chutney...</p>
<h2>South India</h2>
<h3>Masala Dosa</h3>
<p>A thin rice crepe filled with potato masala...</p>
Reading only the headings gives a clear table of contents: one page title, two regions, and dishes under each region. The indentation here is only for readability; HTML ignores it.
Building a logical outline
A few simple rules keep the outline clean:
- Use one
<h1>per page for its main title. It usually matches what the page is about and is similar to the<title>. - Go down one level at a time. After an
<h2>, the next sub-heading is an<h3>, not an<h4>. - You may jump back up any number of levels when a new major section starts, such as from
<h4>straight to<h2>. - Most pages never need
<h5>or<h6>. If you find yourself there often, the page may be trying to do too much.
Why headings matter for accessibility
Many screen reader users navigate by headings. They pull up a list of all headings, or press a key to jump from one to the next, much as sighted people skim bold titles. If headings are missing, or are just bold paragraphs, these users must listen to the entire page to find what they want. Skipped levels make the structure confusing, because it seems like a section is missing.
The big mistake: choosing a heading for its size
The most common misuse is picking <h4> because it "looks the right size", or using <h1> for any text that should be big. This breaks the outline. The correct approach is to choose the level by structure, then style it:
h2 {
font-size: 1.5rem;
margin-top: 2rem;
}
.card-title {
font-size: 1.125rem;
font-weight: 700;
}
The reverse mistake is just as common: making a paragraph bold and large with CSS when it really is a section title. If it introduces a section, it should be a heading element.
Also avoid using headings for things that are not titles, such as a phone number in a banner or a slogan. Big text is not automatically a heading.
Writing useful heading text
Headings work best when they describe the section that follows, so someone reading only the headings understands the page. "Opening hours" is more helpful than "Info". Keep them short, put the key words first, and avoid repeating the same heading text several times on one page.
Summary: one <h1>, levels in order, chosen for structure rather than size, and text that describes what comes next.
Ready to master real-world web development?
Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.