Skip to content
Web Design & Development

A Practical Guide to Semantic HTML

Using the HTML element that describes what a thing is — nav, main, button, table, heading levels — rather than styling a generic div to look like it.

MediaScaleUp Editorial Team 2 min read 11 views
A Practical Guide to Semantic HTML

The key figures

Landmark elements
header, nav, main, aside, footer, section, article
One per page
a single main element
Heading structure
one h1, then descending levels without skipping
Native button behavior
keyboard focus, Enter and Space activation, and an implicit role
Cost of replacing a native control
every behavior above must be reimplemented by hand

Why this is worth getting right

Assistive technology, search engines and browser features all read the element, not the appearance, so a div styled as a button is invisible to everything except a sighted mouse user.

Do this, not that

Do

  • Reach for the native element first and add ARIA only when nothing native fits
  • Keep heading levels sequential so a screen reader user can navigate the outline
  • Use button for actions and a for navigation, decided by what happens on activation
  • Mark up tabular data as a table with proper header cells rather than as stacked divs
  • Label form controls with a real label element associated to the input

Don’t

  • Div with a click handler standing in for a button
  • Choosing heading levels for their font size rather than their place in the outline
  • Adding ARIA roles to elements that already have the right role
  • Using section as a generic wrapper where a div would be correct

When to bring in help

Our advice Bring in help when an accessibility audit lists structural issues across every template, when a component library has replaced native controls wholesale, or when a framework is generating the markup and you cannot change it directly.

Where this comes from

The figures and practices above come from the sources listed.

Working on something like this?

We take on Web Design & Development work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.

Where to go next

Spotted something wrong? Report an error on this page. We correct on the page and say what changed.

All services

The work behind this article, and what it costs.

MediaScaleUp Editorial Team

Articles here are researched, written and checked by the MediaScaleUp studio team before they are published, and dated when they are reviewed.

Keep reading

More in Web Design & Development