How to Choose Semantic HTML Tags for Accessible Pages
In this article
Choosing the right semantic HTML tags is one of the simplest ways to make your web pages clearer for both users and assistive technologies like screen readers. Semantic tags describe the meaning of content (e.g., <nav> for navigation, <article> for a self-contained piece), not just its appearance. This improves accessibility, SEO, and code maintainability. You don’t need any special tools—just a text editor and a basic understanding of HTML.
What You'll Need
- A text editor or IDE (like VS Code, Sublime Text, or Notepad++)
- A web browser for testing
- Basic familiarity with HTML tags and attributes
- Optional: a browser extension like WAVE or Lighthouse for accessibility checks
Step-by-Step
- Start with the HTML5 structural elements. Use
<header>for introductory content,<nav>for navigation links,<main>for the primary content,<article>for self-contained content like blog posts,<section>for thematic grouping,<aside>for tangential content like sidebars, and<footer>for closing information. These replace generic<div>elements and give structure to the page. - Use headings hierarchically. Place a single
<h1>for the page’s main title, then use<h2>for major sections,<h3>for subsections, and so on. Do not skip levels (e.g., jumping from<h2>to<h4>)—this confuses screen reader users who rely on heading order to navigate. - Wrap lists in the appropriate list tags. Use
<ul>for unordered lists (bullets),<ol>for ordered lists (numbers), and<dl>for description lists (terms and definitions). Each list item goes inside<li>(or<dt>/<dd>for description lists). This signals to assistive tech how many items are in the list and their order. - Mark up links and buttons correctly. Use
<a>for navigation to another page or anchor, and<button>for actions like submitting a form or toggling a menu. Do not use<div>with an onclick handler—it’s not keyboard-accessible by default. If you must use a<div>, addrole="button"andtabindex="0", but prefer native elements. - Use
<figure>and<figcaption>for images with captions. Wrap an image and its caption in a<figure>element, and use<figcaption>for the caption text. This associates the caption with the image programmatically, which helps screen reader users understand the context. - Provide text alternatives for media. Always add an
altattribute to<img>tags describing the image’s purpose. For complex images like charts, use a longer description in the surrounding text or alongdescattribute (though support is limited). For video and audio, include transcripts or captions. - Use
<table>only for tabular data. If you need to display data in rows and columns, use a<table>with<thead>,<tbody>, and<th>for headers. Use thescopeattribute on<th>to indicate whether it’s a row or column header. Do not use tables for layout—use CSS instead. - Emphasize text with
<strong>and<em>. Use<strong>for important text (rendered bold) and<em>for emphasis (rendered italic). These convey meaning to screen readers, unlike<b>and<i>, which are purely presentational. - Use
<blockquote>for long quotations. If you quote a large block of text, wrap it in<blockquote>. For short inline quotes, use<q>. This helps assistive tech identify quoted content. - Add
langattribute to the<html>tag. Set the primary language of the page, likelang="en". This helps screen readers pronounce text correctly and is essential for accessibility.
Common Mistakes
- Using
<div>for everything. While it’s tempting to wrap everything in a<div>for styling, this removes semantic meaning. Always prefer a semantic tag if one exists. - Skipping heading levels. Jumping from
<h2>to<h4>breaks the outline. Maintain a logical hierarchy. - Using
<br>to create spacing. This is a presentational hack. Use margins or padding in CSS instead. - Putting block elements inside
<p>. For example, a<div>inside a<p>is invalid HTML and can confuse browsers. Keep<p>for text only. - Using
<b>and<i>for emphasis. These are presentational; use<strong>and<em>instead. - Forgetting the
altattribute on images. Decorative images can havealt=""to be ignored by screen readers, but informative images need a descriptive alt text.
Tips
- Think about the document outline. Before writing HTML, sketch the structure of your content as a hierarchy. This will guide your choice of tags.
- Use the
<main>tag once per page. It helps screen reader users jump directly to the main content. - Test with a screen reader. Tools like NVDA (Windows) or VoiceOver (Mac) are free and give you insight into how your page is interpreted.
- Keep CSS separate. Semantic HTML is about structure, not style. Use classes and IDs for styling, not tags.
- Validate your HTML. Use the W3C Markup Validation Service to catch errors that might affect accessibility.
Troubleshooting
If your page doesn’t seem to be accessible or the structure feels off, try these steps:
- Check the outline. Use a browser extension like HeadingsMap to see the heading structure. If it’s messy, fix the heading levels.
- Verify the
langattribute. If screen readers pronounce text incorrectly, ensure thelangattribute is set on the<html>element. - Inspect the HTML. Use the browser’s developer tools to see if any tags are incorrectly nested. The validator can help.
- Test keyboard navigation. Make sure all interactive elements are reachable with the Tab key and that focus indicators are visible.
- If a screen reader skips content, check if you’ve used
aria-hiddenincorrectly or if the content is inside a<div>without a role. Consider using ARIA roles sparingly—native semantics are better.
Frequently Asked Questions
What is the difference between <section> and <article>?
<article> is for self-contained content that could be syndicated, like a blog post or news story. <section> is for grouping related content within a page, often with a heading. Use <section> to break up a long article into chapters, and <article> for each standalone piece.
Can I use multiple <h1> tags on a page?
Technically, HTML5 allows multiple <h1> tags if they are inside different sectioning elements, but it’s best practice to use only one <h1> per page for clarity. Screen reader users often rely on the <h1> to understand the page’s purpose.
When should I use <aside>?
Use <aside> for content that is tangentially related to the main content, like a sidebar with related links, a pull quote, or an advertisement. It should be distinguishable from the main content.
Is it okay to use <div> for layout?
Yes, <div> is fine for layout when no semantic tag fits. For example, a wrapper for a grid layout is a good use. The key is to use semantic tags when they represent the content’s meaning.
Do I need ARIA roles if I use semantic HTML?
No, semantic HTML provides built-in ARIA roles. Adding ARIA roles to semantic tags is redundant and can cause confusion. Use ARIA only when there is no native HTML element that conveys the needed meaning, such as for custom widgets.
How do I handle images that are purely decorative?
Set the alt attribute to an empty string (alt="") so screen readers skip them. Do not use the alt attribute for text like “image” or “photo.”