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.
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.
Buttons and links
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.
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:
<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.
<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
alttext, not every visual detail. - Give decorative images an empty
altattribute 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-labelor 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.