HTML Lesson 22 – Accessibility Basics | Dataplexa
Lesson 22

Accessibility Basics

Learn essential accessibility principles to make Alex's portfolio usable by everyone, including people with disabilities

Web accessibility means building websites that work for everyone. Including people who are blind, deaf, have motor difficulties, or use assistive technologies. Around 15% of the world's population has some form of disability. That's over one billion people who might struggle to use websites that aren't built with accessibility in mind. Think of accessibility like building ramps alongside stairs. The stairs work fine for most people, but the ramp ensures everyone can get where they need to go. Good accessibility doesn't just help disabled users — it makes websites better for everyone. Alex's portfolio needs to work for all visitors, regardless of their abilities. A visitor might be using a screen reader to hear the content, navigating with only a keyboard, or have difficulty distinguishing colors. Let's explore the fundamental principles.

The Four Principles of Accessibility

Web accessibility follows four core principles, known as POUR. Every decision you make should consider these guidelines:

Perceivable

Information must be presented in ways users can perceive — text alternatives for images, captions for videos

Operable

Interface components must be operable — keyboard navigation, no seizure-inducing flashes

Understandable

Information and UI operation must be understandable — clear language, predictable functionality

Robust

Content must work with assistive technologies — proper HTML structure, valid code

Semantic HTML Foundation

The most important accessibility feature costs nothing and requires no extra code — using HTML elements for their intended purpose. Screen readers and other assistive technologies rely on proper HTML structure to understand your content. When you use <h1> for headings instead of <div class="big-text">, screen readers can jump between headings. When you use <button> instead of styled divs, keyboard users can activate them with the space bar or Enter key.
<!-- Semantic structure for Alex's portfolio header -->
<header>
  <h1>Alex Thompson</h1> <!-- Main heading, announces page purpose -->
  <nav> <!-- Navigation landmark for screen readers -->
    <ul>
      <li><a href="index.html">Home</a></li> <!-- Proper link structure -->
      <li><a href="projects.html">Projects</a></li>
      <li><a href="contact.html">Contact</a></li>
    </ul>
  </nav>
</header>

<main> <!-- Main content landmark -->
  <section>
    <h2>About Me</h2> <!-- Proper heading hierarchy -->
    <p>I'm a web developer passionate about creating accessible experiences.</p>
  </section>
</main>
localhost/index.html

What just happened?

The semantic HTML creates invisible landmarks that assistive technologies can navigate. Screen readers announce "banner" for header, "navigation" for nav, and "main" for main content. The heading hierarchy lets users jump between sections. Try this: Install a screen reader extension and hear how it announces each element.

Images and Alternative Text

Every image needs alternative text that describes its content or purpose. Screen readers announce this text instead of showing the image. But not all images need the same type of description. Informative images convey information that's not available in surrounding text. Decorative images are purely visual and should have empty alt text. Functional images like buttons or icons need alt text describing their action.
<!-- Different types of images in Alex's portfolio -->
<section>
  <h2>My Photo</h2>
  <!-- Informative: describes the image content -->
  <div style="background:#e2e8f0;padding:40px;text-align:center;color:#64748b;border-radius:8px;">
    [Photo: Alex at desk with laptop and coffee, smiling at camera]
  </div>
  
  <h3>Skills</h3>
  <ul>
    <li>
      <!-- Functional: describes what clicking does -->
      <div style="display:inline-block;width:16px;height:16px;background:#22c55e;border-radius:2px;margin-right:8px;"></div>
      HTML &amp; CSS
    </li>
    <li>
      <div style="display:inline-block;width:16px;height:16px;background:#3b82f6;border-radius:2px;margin-right:8px;"></div>
      JavaScript
    </li>
  </ul>
  
  <!-- Decorative: empty alt because it's just visual flourish -->
  <div style="background:#f3f4f6;height:2px;width:100%;margin:20px 0;"></div>
</section>
localhost/index.html

Common Alt Text Mistakes

Don't start alt text with "Image of" or "Picture showing" — screen readers already announce it's an image. Don't repeat information from surrounding text. For decorative images, use empty alt="" rather than skipping the attribute entirely, which makes screen readers read the filename.

Color and Contrast

Color alone should never be the only way to convey information. Some users are colorblind, others use high-contrast modes that remove colors entirely. Always provide additional visual cues beyond color. Text contrast ratios determine readability. Normal text needs a 4.5:1 ratio against its background. Large text (18px+ or 14px+ bold) needs 3:1. White text on a medium gray background often fails these requirements.

Good Contrast

White text on dark background (21:1 ratio)
Dark text on white background (21:1 ratio)

Poor Contrast

Light text on light gray (1.7:1 ratio)
Very light text on white (1.2:1 ratio)
Alex's portfolio should use multiple visual cues to communicate status or categories. Instead of just changing colors, combine color with icons, text labels, or patterns.
<!-- Project status using color AND text/icons -->
<section>
  <h2>Project Status</h2>
  
  <div style="margin-bottom:16px;">
    <!-- Multiple indicators: color, icon, and text -->
    <span style="background:#22c55e;color:white;padding:4px 8px;border-radius:4px;font-size:12px;font-weight:bold;">
      ✓ Complete
    </span>
    <span style="margin-left:10px;">E-commerce Website</span>
  </div>
  
  <div style="margin-bottom:16px;">
    <span style="background:#f59e0b;color:white;padding:4px 8px;border-radius:4px;font-size:12px;font-weight:bold;">
      → In Progress
    </span>
    <span style="margin-left:10px;">Portfolio Redesign</span>
  </div>
  
  <div>
    <span style="background:#6b7280;color:white;padding:4px 8px;border-radius:4px;font-size:12px;font-weight:bold;">
      ○ Planned
    </span>
    <span style="margin-left:10px;">Mobile App</span>
  </div>
</section>
localhost/index.html

Even colorblind users can distinguish project status because each uses a different icon (checkmark, arrow, circle) plus descriptive text. The color enhances the information rather than being the only indicator.

Keyboard Navigation

Many users navigate websites without a mouse — using keyboards, switch devices, or voice commands. Every interactive element must be reachable and usable via keyboard. The Tab key moves forward through focusable elements, Shift+Tab moves backward. Focus indicators show which element currently has keyboard focus. Browsers provide default focus styles, but many developers remove them for aesthetic reasons. Always replace removed focus styles with custom alternatives. Interactive elements should appear in logical tab order. A user tabbing through Alex's portfolio should encounter the navigation links, then main content buttons, then footer links. Skip links let keyboard users jump to main content without tabbing through every navigation item.
<!-- Keyboard-accessible navigation with skip link -->
<body>
  <!-- Skip link appears on focus -->
  <a href="#main" style="position:absolute;top:-40px;left:6px;background:#0f172a;color:#fff;padding:8px;text-decoration:none;z-index:100;">
    Skip to main content
  </a>
  
  <header>
    <nav>
      <ul style="list-style:none;padding:0;display:flex;gap:20px;">
        <li><a href="index.html" style="padding:8px 12px;border:2px solid transparent;">Home</a></li>
        <li><a href="projects.html" style="padding:8px 12px;border:2px solid transparent;">Projects</a></li>
        <li><a href="contact.html" style="padding:8px 12px;border:2px solid transparent;">Contact</a></li>
      </ul>
    </nav>
  </header>
  
  <main id="main"> <!-- Skip link target -->
    <button style="padding:10px 20px;background:#3b82f6;color:white;border:none;border-radius:4px;cursor:pointer;">
      Download Resume
    </button>
  </main>
</body>
localhost/index.html

What just happened?

The skip link stays hidden until someone tabs to it, then appears for keyboard navigation. All interactive elements (links and buttons) receive keyboard focus automatically. The id="main" attribute creates a target for the skip link. Try this: Click in the example and press Tab to see the focus indicators.

Form Accessibility

Forms create the biggest accessibility barriers when done wrong, but become incredibly usable when done right. Every form control needs a proper label that describes its purpose. Error messages should be clearly associated with their inputs and explain how to fix problems. Label elements explicitly connect descriptive text to form inputs. Screen readers announce labels when focus moves to their associated controls. Placeholder text disappears when typing begins and has poor color contrast, so never rely on it for essential instructions.
<!-- Accessible contact form for Alex's portfolio -->
<form>
  <h2>Contact Me</h2>
  
  <div style="margin-bottom:20px;">
    <label for="name" style="display:block;margin-bottom:4px;font-weight:bold;">
      Full Name (required)
    </label>
    <input type="text" id="name" name="name" required 
           style="width:100%;padding:8px;border:2px solid #d1d5db;border-radius:4px;font-size:16px;">
  </div>
  
  <div style="margin-bottom:20px;">
    <label for="email" style="display:block;margin-bottom:4px;font-weight:bold;">
      Email Address (required)
    </label>
    <input type="email" id="email" name="email" required
           style="width:100%;padding:8px;border:2px solid #d1d5db;border-radius:4px;font-size:16px;">
  </div>
  
  <div style="margin-bottom:20px;">
    <label for="message" style="display:block;margin-bottom:4px;font-weight:bold;">
      Your Message
    </label>
    <textarea id="message" name="message" rows="4"
              style="width:100%;padding:8px;border:2px solid #d1d5db;border-radius:4px;font-size:16px;resize:vertical;"></textarea>
  </div>
  
  <button type="submit" style="background:#22c55e;color:white;padding:12px 24px;border:none;border-radius:4px;font-size:16px;cursor:pointer;">
    Send Message
  </button>
</form>
localhost/contact.html
The for attribute connects each label to its input using the input's id. Required fields are marked both visually (in the label) and programmatically (with the required attribute). Form inputs use appropriate types like email for better mobile keyboards and validation.

Testing Your Accessibility

Accessibility testing doesn't require expensive tools. Start with built-in browser features and simple manual tests. These catch most common issues before users encounter them.
1

Tab Through Your Site

Can you reach every interactive element? Is the focus indicator visible? Does the tab order make logical sense?

2

Turn Off CSS

Does your content still make sense? Can you understand the page structure and navigation?

3

Check Color Contrast

Use browser developer tools or online contrast checkers to verify text meets WCAG standards.

Browser developer tools include accessibility audits that scan for common issues. Chrome DevTools highlights elements with insufficient contrast, missing alt text, or keyboard navigation problems. But automated tools only catch about 30% of accessibility issues — manual testing with real users provides the complete picture. Real accessibility happens when you build with inclusive principles from the start, not when you retrofit existing code. Alex's portfolio should welcome every visitor, regardless of how they browse the web.

Quiz

What's the most important foundation for web accessibility?

Alex adds a decorative border image to their portfolio that serves no informational purpose. What alt text should it have?

What are the minimum color contrast ratios required for accessible text?

Next: ARIA Attributes

Master ARIA labels, roles, and properties to enhance accessibility for complex interactive components and dynamic content.