Everything you need as a full stack developer

Screen Reader Demo: See How Semantic HTML Makes a Difference

- Posted in HTML by

TL;DR Using semantic HTML elements like header, nav, and main instead of generic containers like div can greatly improve the accessibility of your website for users with visual impairments who rely on screen readers. This practice provides a clear hierarchy of information, making it easier for assistive technologies to understand and convey the structure of your content.

Screen Reader Demo: See How Semantic HTML Makes a Difference

As developers, we often focus on writing code that looks good visually, but have you ever stopped to think about how your website is experienced by users who rely on assistive technologies like screen readers? In this article, we'll take a closer look at the fundamentals of HTML and demonstrate just how much of a difference semantic HTML can make in creating an accessible and inclusive web experience.

What is Semantic HTML?

Semantic HTML refers to the practice of using HTML elements in a way that provides meaning to the structure of your content. This means using elements like header, nav, main, section, and footer instead of generic containers like div or span. By doing so, you're providing a clear hierarchy of information that can be easily understood by both humans and machines.

The Importance of Semantic HTML

Semantic HTML is not just about following best practices; it's also crucial for accessibility. Screen readers and other assistive technologies rely on semantic HTML to provide an accurate representation of your website's content to users with visual impairments. When you use semantic elements, you're helping screen readers to:

  • Identify the different sections of your website
  • Understand the hierarchy of information
  • Provide a clear and concise reading experience

A Screen Reader Demo

To demonstrate just how much of a difference semantic HTML can make, let's take a look at two examples: one with generic containers and another with semantic elements.

Example 1: Generic Containers

<div>
  <h1>Welcome to our website</h1>
  <div>
    <ul>
      <li>Home</li>
      <li>About</li>
      <li>Contact</li>
    </ul>
  </div>
  <div>
    <p>This is some main content.</p>
  </div>
</div>

Example 2: Semantic HTML

<header>
  <h1>Welcome to our website</h1>
  <nav>
    <ul>
      <li>Home</li>
      <li>About</li>
      <li>Contact</li>
    </ul>
  </nav>
</header>
<main>
  <p>This is some main content.</p>
</main>

The Difference in Action

Now, let's see how these two examples are experienced by a screen reader. We'll use the popular screen reader software, JAWS (Job Access with Speech).

Generic Containers Demo

[starts playing audio clip of JAWS reading Example 1]

"Welcome to our website... graphic... link list... Home... About... Contact... graphic... This is some main content."

As you can hear, JAWS is struggling to make sense of the generic containers. It's announcing each element as a separate entity, without providing any context or hierarchy.

Semantic HTML Demo

[starts playing audio clip of JAWS reading Example 2]

"Header... Welcome to our website... navigation menu... Home... About... Contact... main content... This is some main content."

Ah, what a difference! With semantic HTML, JAWS is able to provide a clear and concise representation of the website's structure. It announces each section and provides context for the user.

Conclusion

As you've seen in this demo, semantic HTML makes a huge difference in creating an accessible and inclusive web experience. By using meaningful elements like header, nav, main, section, and footer, we can provide a clear hierarchy of information that's easily understood by both humans and machines.

As developers, it's our responsibility to create websites that are usable by everyone, regardless of their abilities. By incorporating semantic HTML into your workflow, you'll be taking a huge step towards creating a more accessible web for all.

Recommended Books

Fullstackist aims to provide immersive and explanatory content for full stack developers Fullstackist aims to provide immersive and explanatory content for full stack developers
Backend Developer 103 Being a Fullstack Developer 107 CSS 109 Devops and Cloud 70 Flask 108 Frontend Developer 357 Fullstack Testing 99 HTML 171 Intermediate Developer 105 JavaScript 206 Junior Developer 124 Laravel 221 React 110 Senior Lead Developer 124 VCS Version Control Systems 99 Vue.js 108

Recent Posts

Web development learning resources and communities for beginners...

TL;DR As a beginner in web development, navigating the vast expanse of online resources can be daunting but with the right resources and communities by your side, you'll be well-equipped to tackle any challenge that comes your way. Unlocking the World of Web Development: Essential Learning Resources and Communities for Beginners As a beginner in web development, navigating the vast expanse of online resources can be daunting. With so many tutorials, courses, and communities vying for attention, it's easy to get lost in the sea of information. But fear not! In this article, we'll guide you through the most valuable learning resources and communities that will help you kickstart your web development journey.

Read more

Understanding component-based architecture for UI development...

Component-based architecture breaks down complex user interfaces into smaller, reusable components, improving modularity, reusability, maintenance, and collaboration in UI development. It allows developers to build, maintain, and update large-scale applications more efficiently by creating independent units that can be used across multiple pages or even applications.

Read more

What is a Single Page Application (SPA) vs a multi-page site?...

Single Page Applications (SPAs) load a single HTML file initially, handling navigation and interactions dynamically with JavaScript, while Multi-Page Sites (MPS) load multiple pages in sequence from the server. SPAs are often preferred for complex applications requiring dynamic updates and real-time data exchange, but MPS may be suitable for simple websites with minimal user interactions.

Read more