Skip to content
A11Y-01Beginner4 min read

Semantic HTML first

Landmarks, headings and native controls give you accessibility for free. Learn what each element brings.

Updated

The fastest way to build an accessible interface is to use the elements HTML already has. Native elements come with keyboard support, focus handling and meaning that assistive technology understands, and you get all of it without writing a single line of JavaScript.

Why semantics matter

Screen readers, voice control software and browser features such as reader mode do not see your CSS. They read the accessibility tree, a version of the page built from element types, names and states. A <div> styled to look like a button is just an anonymous box in that tree.

<div class="header">
  <div class="logo">Strata</div>
  <div class="nav">
    <div class="link" onclick="go('/learn')">Learn</div>
  </div>
</div>
<div class="content">
  <div class="title">Semantic HTML first</div>
  <div class="button" onclick="save()">Save</div>
</div>

Both versions can look identical. Only the second one can be navigated by landmark, announces a heading and a button, works with the keyboard and survives being read aloud.

Landmarks

Landmark elements describe the regions of a page. Screen reader users jump between them the way sighted users glance at a layout, so a page with good landmarks is quick to scan.

ElementRoleUse it for
<header>banner, when it is not inside another landmarkThe site header with the logo and main navigation
<nav>navigationGroups of links; label each one when there are several
<main>mainThe primary content, exactly once per page
<aside>complementaryRelated content such as a table of contents
<footer>contentinfo, when it is not inside another landmarkThe site footer
<section>region, when it has an accessible nameA labelled part of a page

Headings create the outline

Many screen reader users move through a page by headings before reading anything else. Use one <h1> per page, do not skip levels, and choose heading levels for structure rather than size. Size is a styling decision; structure is not.

Links go somewhere; buttons do something. A link changes the URL and can be opened in a new tab or bookmarked. A button submits a form, opens a dialog or toggles a setting.

You need toUseAvoid
Go to another page<a href>A button whose click handler changes the location
Perform an action<button type="button"><a href="#"> with a click handler
Submit a form<button type="submit">A styled <div> with a click handler

A native button is focusable, activates with Enter and Space, works with voice control and announces itself as a button. Recreating that on a <div> takes all of this:

TSX
<div
  role='button'
  tabIndex={0}
  onClick={save}
  onKeyDown={(event) => {
    if (event.key === 'Enter' || event.key === ' ') {
      event.preventDefault()
      save()
    }
  }}
>
  Save
</div>

And it still does not submit forms or support the disabled attribute. Use <button>.

Forms and labels

Every input needs a label that is connected to it in code, not just placed near it. Placeholders are not labels: they disappear as soon as someone starts typing and often have poor contrast.

HTML
<label for="email">Email address</label>
<input
  id="email"
  type="email"
  autocomplete="email"
  required
  aria-describedby="email-hint"
/>
<p id="email-hint">We only use it to send your certificate.</p>

Images and alternative text

  • Describe the purpose of an informative image in its alt text, not every visual detail.
  • Give decorative images an empty alt attribute so screen readers skip them.
  • Keep text in HTML rather than inside images, so it can be translated, resized and read aloud.
  • Icon only buttons still need a name: add aria-label or visually hidden text.

Summary

  • Assistive technology reads the accessibility tree, not your styles.
  • Landmarks and a clean heading outline make pages fast to navigate.
  • Links navigate, buttons act; native elements bring keyboard support for free.
  • Every input needs a real label, and color is never the only signal.

Finished this lesson?

Mark it complete to track your progress across every track in the curriculum.