Lesson 5 of 5 · 5 min
Semantic HTML and accessibility
Landmarks like header, nav, main and footer, articles and sections, tables for data, and a short checklist for accessible, search-friendly pages.
On this page
Semantic HTML means choosing elements for what content is, not how it looks. A <button> is a button; a <div> styled to look like one is not.
It matters because:
- Accessibility: screen readers and other assistive tools rely on the elements to describe the page and let people jump around it.
- Free behaviour: a real
<button>works with the keyboard and announces itself correctly. A<div onclick>does neither. - Search engines understand the structure and content better.
- Your code is easier to read and style.
Page landmarks
<body>
<header>
<a href="/">Khan Waseem</a>
<nav aria-label="Main">
<ul>
<li><a href="/courses">Courses</a></li>
<li><a href="/blog">Blog</a></li>
</ul>
</nav>
</header>
<main>
<article>
<h1>CSS Grid</h1>
<p>...</p>
</article>
<aside>Related lessons</aside>
</main>
<footer>© 2026</footer>
</body>
| Element | Meaning |
|---|---|
header |
Introductory content: logo, site navigation, or a heading block |
nav |
A major group of navigation links |
main |
The main content. Exactly one per page |
article |
Self-contained content that makes sense alone: a post, a lesson, a product card |
section |
A themed group within a page, normally with its own heading |
aside |
Related but secondary content: a sidebar, a table of contents |
footer |
Closing content: copyright, contact links |
div and span have no meaning. They are still useful as hooks for styling, when no semantic element fits.
Tables are for data
Use tables for tabular data, never for layout:
<table>
<caption>Course lessons</caption>
<thead>
<tr><th scope="col">Lesson</th><th scope="col">Minutes</th></tr>
</thead>
<tbody>
<tr><th scope="row">The box model</th><td>8</td></tr>
<tr><th scope="row">Flexbox</th><td>10</td></tr>
</tbody>
</table>
th with scope tells assistive tech which header applies to each cell.
Buttons versus links
- A link (
<a href>) goes somewhere: another page or a part of this one. - A button (
<button>) does something: submit, open a menu, toggle a theme.
If you pick the right one, keyboard and screen reader support come for free.
ARIA, briefly
ARIA attributes add accessibility information that HTML can't express, such as aria-expanded="true" on a menu button or aria-current="page" on the active nav link. The first rule of ARIA is: if a native HTML element does the job, use it instead. Wrong ARIA is worse than none.
An accessibility checklist
- The page has a
lang, a uniquetitle, and exactly oneh1. - Headings follow a logical outline.
- Every image has suitable
alttext (empty for decorative images). - Every form input has a
label. - Everything works with the keyboard alone: Tab through the page, and press Enter or Space on controls.
- Focus is always visible.
- Text has enough contrast with its background (at least 4.5:1 for body text).
- Link text makes sense out of context.
- Video has captions.
Try it
Rebuild a page you made earlier using header, nav, main, article and footer. Then unplug your mouse (or just don't touch it) and use the page with Tab, Shift+Tab and Enter. Anything you can't reach or can't see focused is a bug to fix.
That completes the HTML Crash Course. Next, make it look good in CSS Crash Course.
More from HTML Crash Course
- Lesson 1 · 5 minYour first HTML documentElements, tags and attributes, the boilerplate every page needs, and what each line of it does.
- Lesson 2 · 5 minText, lists and linksHeadings and their outline, paragraphs and inline text, ordered and unordered lists, and links to other pages, sections, email and files.
- Lesson 3 · 5 minImages and mediaImages with good alt text, figures and captions, responsive images with srcset and picture, lazy loading, video, audio and embeds.