What is semantic HTML and why does it matter?
Semantic HTML uses elements that describe the meaning of content, not just its look: <header>, <nav>, <main>, <article>, <section>, <aside>, <footer>, <button>, <form>, <label>, <table> and headings <h1> to <h6> in order.
Why it matters
- Accessibility: screen readers announce landmarks and roles, and users jump between headings and regions. A
<div onclick>is invisible to the keyboard and assistive technology; a<button>is focusable, works with Enter and Space, and is announced as a button for free. - SEO: search engines understand the page structure.
- Maintainability: the markup explains itself.
- Built-in behaviour:
<form>submits on Enter,<details>toggles,<dialog>handles focus and Escape,<input type="email">validates and shows the right mobile keyboard.
Rules of thumb
- Use a
<button>for actions and an<a href>for navigation. - One
<main>per page, and headings that do not skip levels. - Every form field has a
<label>; every meaningful image hasalttext (alt=""for decorative ones). - Use ARIA only when no native element exists. The first rule of ARIA is: do not use ARIA if HTML can do it.
Example
html
<header>
<nav aria-label="Main">
<a href="/">Home</a>
<a href="/jobs" aria-current="page">Jobs</a>
</nav>
</header>
<main>
<article>
<h1>Frontend Engineer</h1>
<p>Remote · Full time</p>
<form>
<label for="email">Email</label>
<input id="email" type="email" required autocomplete="email" />
<button type="submit">Apply</button>
</form>
</article>
</main>
<footer>© 2026</footer>Follow-up questions interviewers ask
Try answering each one before you open it.
How do you test accessibility quickly?
Navigate with only the keyboard (Tab, Shift+Tab, Enter, Space, Escape) and check that focus is always visible. Run Lighthouse or the axe DevTools extension, try a screen reader (VoiceOver, NVDA), and add jest-axe or Playwright's axe integration to CI. Automated tools find only about a third of issues, so manual checks still matter.