Skip to content

Lesson 1 of 9 · 22m

Semantic HTML First: The Accessible Interface You Already Have

Why elements carry behavior and meaning, how div-first markup creates invisible work, and the day-one habit that prevents most accessibility defects.

The most expensive accessibility bug I ever inherited was a checkout flow built entirely from divs and spans. It looked polished. It also had no keyboard operability, no names, no landmarks, and no reliable tab order. The fix was not clever ARIA; it was deleting custom widgets and using the elements browsers already ship with behavior attached.

HTML is an accessibility API

When you write this:

<button type="submit">Save changes</button>

the browser exposes a button role, an accessible name, keyboard activation for Enter and Space, focusability, click handling, and default disabled behavior. A div gives you none of it:

<!-- Looks like a button; is not one. -->
<div class="btn" onclick="save()">Save changes</div>

That second version needs tabindex, keydown logic, role, a name, pointer and keyboard parity, disabled semantics, focus styling, and regression tests. Most teams never finish that list.

Use structure before decoration

<body>
  <header>Site header</header>
  <nav aria-label="Primary">...</nav>
  <main>
    <h1>Billing settings</h1>
    <section aria-labelledby="invoices-heading">
      <h2 id="invoices-heading">Invoices</h2>
    </section>
  </main>
  <aside aria-label="Related help">...</aside>
</body>

These are not decorative containers. Landmarks let screen-reader users jump straight to navigation, main content, or complementary material. Headings become an outline. Native elements become operable controls. The document starts making sense before CSS loads.

The practical rule

Choose the least powerful element that truthfully describes the thing. A link navigates; a button acts; a heading labels a section; a list groups repeated items. If you are about to write event handlers on a div, stop and ask what native element you are reinventing.

Field notes

  • div and span are valid layout tools, but they are empty semantics; never use them as interactive controls.
  • href matters: <a> without href is not focusable or announced as a link in the normal way.
  • CSS can make a real control look like anything; the reverse is not true.
  • The first accessibility test is cheap: open the page source and ask whether the meaning survives without CSS or JavaScript.

Was this lesson helpful?

Sign in to rate