Skip to content

03. Accessibility

Web accessibility ensures that websites are usable by people with disabilities, including those using screen readers, keyboard navigation, and other assistive technologies. HTML provides semantic elements and attributes that improve accessibility. Creating accessible HTML benefits all users and is often required by law.

<nav aria-label="Main navigation">
<ul>
<li><a href="/">Home</a></li>
</ul>
</nav>
<main>
<article>
<h1>Article Title</h1>
<p>Content...</p>
</article>
</main>
<button aria-label="Close dialog">×</button>
<input type="text" aria-describedby="help-text">
<p id="help-text">Helpful instructions</p>
<span aria-hidden="true">Decorative icon</span>
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<input type="email" aria-invalid="true" aria-describedby="error">
<span id="error" role="alert">Invalid email</span>
<img src="photo.jpg" alt="Description of the image">
<img src="decoration.jpg" alt="" role="presentation">
<!-- Good: Semantic -->
<nav>Navigation</nav>
<main>Content</main>
<!-- Avoid: Non-semantic -->
<div class="nav">Navigation</div>
<img src="chart.jpg" alt="Sales increased 20% in Q4">