Semantic HTML as the Foundation
Use native HTML elements like button, nav, and heading to get built-in accessibility for free, before reaching for ARIA.
Semantic HTML as the Foundation is a free Frontend Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Frontend Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Semantic HTML Is Free Accessibility
Using the right HTML element gives you keyboard support, screen reader announcements, and correct ARIA roles for free. Most accessibility problems come from using div + JavaScript instead of the native element.
button vs div with onClick
A <button> is focusable, announces 'button' to screen readers, fires click on Enter/Space, and works with form submit. A <div onClick> has none of these.
<!-- BAD: not keyboard accessible, not announced -->
<div class="btn" onclick="submit()">Save</div>
<!-- GOOD: full accessibility for free -->
<button type="button" onclick="submit()">Save</button>Use button for Buttons, a for Links
If the action navigates to a URL, use <a href>. If the action does something on the page, use <button>. Don't use anchors as buttons (no href, just onclick) — confusing for assistive tech.
Headings Form a Document Outline
Use h1-h6 in order to create a logical outline. Screen reader users navigate via headings — skipping levels (h1 -> h3) creates confusing gaps.
<h1>Article Title</h1>
<h2>Section One</h2>
<h3>Subsection</h3>
<h2>Section Two</h2>
<!-- BAD: skipping levels -->
<h1>Title</h1>
<h4>Section</h4>Landmark Elements
HTML5 landmark elements (header, nav, main, aside, footer) let screen reader users jump between major regions. One <main> per page.
<header>
<nav>
<a href="/">Home</a>
</nav>
</header>
<main>
<h1>Page Title</h1>
<article>...</article>
<aside>Sidebar</aside>
</main>
<footer>...</footer>List Elements
Use <ul> for unordered lists, <ol> for ordered, <dl> for definition lists. Screen readers announce 'list of N items' — a meaningful navigation hint.
<ul>
<li>Apples</li>
<li>Bananas</li>
<li>Cherries</li>
</ul>
<!-- Announced: 'list with 3 items' -->Forms: label Every Input
Every input needs an associated <label>. The for/id pair links them — clicking the label focuses the input, and screen readers announce the label when focus arrives.
<label for="email">Email</label>
<input id="email" name="email" type="email">
<!-- Or wrap (no for/id needed): -->
<label>
Email
<input name="email" type="email">
</label>fieldset and legend for Groups
Group related inputs (e.g., radio buttons) with <fieldset> + <legend>. Screen readers announce the legend each time a member input receives focus.
<fieldset>
<legend>Choose a plan</legend>
<label><input type="radio" name="plan" value="free"> Free</label>
<label><input type="radio" name="plan" value="pro"> Pro</label>
</fieldset>table Elements for Tabular Data
Use <table> with <thead>, <tbody>, <th scope="col"> — never use tables for layout. Screen readers navigate cells in two dimensions and announce headers.
article, section, and figure
<article>: self-contained content (blog post, comment). <section>: thematic grouping with a heading. <figure> + <figcaption>: media with caption.
ARIA Only When Necessary
The first rule of ARIA: don't use ARIA. Native HTML always wins. Reach for ARIA only when no semantic element fits your custom widget (combobox, tabs, tree).
Quick Check
Why is <button onclick="..."> preferred over <div onclick="...">?
Recap: Semantic HTML
Use the right element: button for actions, a for navigation, h1-h6 in order for outline, landmark elements (header, nav, main, footer), ul/ol for lists, label for every input, fieldset/legend for radio groups, table for data tables. Native HTML gives accessibility for free. ARIA is a last resort.
Frequently asked questions
Is the “Semantic HTML as the Foundation” lesson free?
Yes — the full text of “Semantic HTML as the Foundation” is free to read here on the web, and the Frontend Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Frontend Academy course, upgrade to CoddyKit PRO.
What will I learn in “Semantic HTML as the Foundation”?
Use native HTML elements like button, nav, and heading to get built-in accessibility for free, before reaching for ARIA. You practise Frontend Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Frontend Academy?
No prior experience is required. Frontend Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Semantic HTML as the Foundation” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Frontend Academy lesson?
Yes. Every Frontend Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- WCAG Levels A AA AAA
- Semantic HTML as the Foundation
- ARIA Roles and Attributes
- Keyboard Navigation and Focus Management