Page structure

Bad example

Welcome
Main page content...
<!-- Bad: divs without semantics -->
<div class="page-header">
  <div class="site-title">My Site</div>
  <div class="navigation">
    <div>Home</div>
    <div>About</div>
  </div>
</div>
<div class="page-content">
  <div class="content-title">Welcome</div>
  <div>Main content...</div>
</div>
<div class="page-footer">
  © 2025 My Site
</div>

Good example

Welcome

Main page content...

© 2025 My Site

<!-- Good: semantic HTML elements -->
<header>
  <div class="site-title">My Site</div>
  <nav aria-label="Main navigation">
    <ul>
      <li><a href="/">Home</a></li>
      <li><a href="/about">About</a></li>
    </ul>
  </nav>
</header>
<main>
  <h1>Welcome</h1>
  <p>Main content...</p>
</main>
<footer>
  <p>© 2025 My Site</p>
</footer>

Explanation: A clear semantic structure helps screen readers navigate and understand content. Sectioning elements (header, nav, main, footer) create important landmarks.

Heading hierarchy

Bad example

Introduction to accessibility

Web accessibility is important...

Basic techniques

Here are some techniques...

Semantic HTML

Semantic HTML...

Structure elements

Elements like header, nav...

CSS and accessibility

CSS can improve...

<!-- Bad: divs with classes for styling -->
<div class="title-large">Introduction</div>
<p>Content...</p>
<div class="title-medium">Section 1</div>
<p>Content...</p>
<div class="title-medium">Section 2</div>
<p>Content...</p>
<div class="title-small">Subsection</div>
<p>Content...</p>

Good example

Introduction to accessibility

Web accessibility is important...

Basic techniques

Here are some techniques...

Semantic HTML

Semantic HTML...

Structure elements

Elements like header, nav...

CSS and accessibility

CSS can improve...

<!-- Good: semantic headings hierarchy -->
<h1>Introduction</h1>
<p>Content...</p>
<h2>Basic techniques</h2>
<p>Content...</p>
<h3>Semantic HTML</h3>
<p>Content...</p>
<h4>Structure elements</h4>
<p>Content...</p>
<h3>CSS and accessibility</h3>
<p>Content...</p>

Explanation: A logical heading hierarchy (h1 → h2 → h3) allows screen readers to create a navigation outline and users to understand the content structure.

Buttons vs clickable elements

Bad example

💾 Save
🗑️ Delete
👤 View profile
ℹ️ More info
<!-- Bad: clickable divs and spans -->
<div @click="handleSave" style="cursor: pointer;">
  💾 Save
</div>
<div @click="handleDelete" style="cursor: pointer;">
  🗑️ Delete
</div>
<span @click="navigateToProfile" style="cursor: pointer;">
  👤 View profile
</span>

Good example

👤 View profile
<!-- Good: buttons for actions, links for navigation -->
<button type="button" @click="handleSave">
  💾 Save
</button>
<button type="button" @click="handleDelete">
  🗑️ Delete
</button>
<a href="/profile">
  👤 View profile
</a>
<button type="button" @click="toggleModal">
  ℹ️ More info
</button>

Explanation: Use the right elements for actions: buttons for actions, links for navigation. This ensures proper semantics and expected keyboard behaviors.

Lists and structured data

Bad example

Ingredients for an omelet:
3 eggs
2 tablespoons of milk
Salt and pepper
1 tablespoon of butter
Steps:
1. Beat eggs with milk
2. Heat the butter
3. Pour eggs and cook
4. Fold in half and serve
<!-- Bad: divs for lists -->
<div class="list-title">Ingredients:</div>
<div>3 eggs</div>
<div>2 tablespoons of milk</div>
<div>Salt and pepper</div>

<div class="list-title">Steps:</div>
<div>1. Beat the eggs</div>
<div>2. Heat the butter</div>
<div>3. Pour and cook</div>

Good example

Ingredients for an omelet:

  • 3 eggs
  • 2 tablespoons of milk
  • Salt and pepper
  • 1 tablespoon of butter

Steps:

  1. Beat eggs with milk
  2. Heat the butter
  3. Pour eggs and cook
  4. Fold in half and serve
<!-- Good: semantic ul and ol -->
<h3>Ingredients:</h3>
<ul>
  <li>3 eggs</li>
  <li>2 tablespoons of milk</li>
  <li>Salt and pepper</li>
</ul>

<h3>Steps:</h3>
<ol>
  <li>Beat the eggs with the milk</li>
  <li>Heat the butter</li>
  <li>Pour and cook</li>
  <li>Fold in half and serve</li>
</ol>

Explanation: Using appropriate list elements allows screen readers to announce the number of items and facilitate navigation.