How to structure headings for web accessibility

Using Headings

When is a heading not a heading? Serious question, the answer lies behind one of the most common accessibility problems on the web.

Headings are much more than a big bold title, they provide a solid structure to the webpage. Think of headings as an outline of your webpage.

The structure should be portrayed both in a visual and technical manner, so people can see the structure, and screen readers are able to identity the structure in order to read it out.

Users who can see the page decide within seconds whether or not the content is relevant to them by skimming through headings, glancing over sub-headings keeping an eye out for significant keywords. Breaking up content with headings allows the page to be easily scanned by the user

Without a heading structure, you force users to do extra work to find the information they’re looking for, who has the time and luxury?

From an accessibility point of view the structure in the code should align with the visual presentation and make sense as a “table of contents” for the page.

Use headings to introduce content, they are labels not statements.

Sections and sub-sections

Have you been structuring headings wrong this whole time? Let’s find out, use this diagram as a guide.

Heading Level Diagram Guide: <h1> Main Heading </h1>, <h2> Sub Heading </h2> <h3> Sub Sub Heading </h3>, <h2> Sub Heading </h2> <h3> Sub Sub Heading </h3> <h3> Sub Sub Heading </h3>, <h4> Sub Sub Sub Heading</h4>

In total, there are six levels of headings you can use to structure sections of content on the page (<h1> through to <h6>).

Heading 1 is the most important and is the heading for the page, this typically corresponds to the title of the page. It gives users an indication of what the page is about - you should have a single Heading 1 on each page.

Each heading 2 creates a section of content. They divide pages into consumable sections which help to organize the content.

When you get to the next heading, ask yourself: Is it a new section? If so then a Heading 2 would be appropriate. If it’s a sub-section of the last heading 2, then a Heading 3 would be suitable. If it’s a sub-section of the last Heading 3, then a Heading 4 would be a good fit, and so on.

Heading visuals

The heading level and visual appearance (e.g. size, boldness) should align, but a page must have a good structure regardless of how it looks.

This has two key implications:

  • Don’t style text to look like a heading unless you use heading mark-up.
  • The level of heading is not the same as the text size.

Skipping heading levels should be avoided (e.g. H1 directly to H3) from an accessibility point of view. People using screen readers often rely on navigating by heading so if the structure isn’t hierarchical they may not understand the relationship.

A good example:

The BBC’s homepage is a good example of how headings should be structured.
An example of BBC's homepage with their heading structure outlined, alongside with an example of a correct heading structure

A single Heading 1 has been used on the page, this is wrapped around the logo (which is appropriate for the homepage only). Visually, the ‘homepage’ aspect is hidden but it is there for assistive technologies to announce.

The different sections of the page are defined as Heading 2s (including some of the items above the heading 1), this allows users to scan the page easily to find the relevant section for them to read. The headlines under each topic are defined as Heading 3s.

In short, this is how the BBC’s homepage structure is broken down:

<h1> BBC Homepage </h1>

<h2> Headline Topic </h2>

<h3> News Headline 1 </h3>

<h3> News Headline 2 </h3>

<h3> News Headline 3 </h3>

<h2> Headline Topic </h2>

<h3> News Headline 1 </h3>

<h3> News Headline 2 </h3>

<h3> News Headline 3 </h3>

A not so obvious good example:

An example of GOV.UK's homepage with their heading structure outlined, alongside with an example of a correct heading structure
The GOV.UKs website is another example of a good heading structure, but visually it’s not as obvious.

Text size doesn’t matter! ‘Popular on GOV.UK’ seems like normal text. The text size is small, it’s not loud and bold, but actually assigning a <h2> to the text is appropriate because it is a whole new section. Would you have guessed that?

There’s no indication of what the big section with links is all about, so how would users of screen readers know?

Guess what, where a section is visually obvious you can hide headings! There is a Heading 2 above the list of links called ‘Services and Information’. It is hidden from sighted users but it will still be read out to users of screen readers.

Let’s take a look at GOV.UKs homepage structure broken down:

<h1> Welcome to GOV.UK </h1>

<h2> Popular on GOV.UK </h2>

<h3> Link 1 </h3>

<h3> Link 2 </h3>

<h3> Link 3 </h3>

<h3> … </h3>

<h2> Services and Information </h2> (hidden)

<h3> Service 1 </h3>

<h3> Service 2 </h3>

<h3> Service 3 </h3>

<h3> … </h3>

The BBC’s and GOV.UKs homepage are very different, visually. Programmatically, they have a solid heading structure which conveys the page structure effectively and keeps users of assistive technology happy!

An example of what not to do:

Take a look at this snippet from an article, that you would assume will make the most out of heading tags.
 An example of headings not being used at the appropriate time in an article along side with an example of the code snippet which shows text has been formatted to give a visual appearance of a heading.
Sure, they look like headings, big and bold, divides the content into small chunks, but don’t be fooled. If we dig deep enough, we’ll find that actually a paragraph tag has been assigned.

Fake heading alert! Avoid formatting text to give a bold or visual appearance of headings without using heading tags.

So the big question, when is a heading not a heading? When it’s just normal text in disguise!

You’re now ready to combat one of the most common accessibility issue on the web.

Add a comment

Fields marked with an asterisk (*) are mandatory.