Skip to content

Accessible HTML Page

Easy ~20 min

What you'll build

An accessible HTML page with a header, nav, main content (heading, paragraph, image with alt, and a labeled form field), and footer — all using semantic elements and ARIA where needed.

Goals

  • Use semantic HTML5 landmarks (header, nav, main, footer)
  • Add alt text to images for screen readers
  • Associate labels with form inputs using for/id
  • Use proper heading hierarchy (h1 → h2 → h3)

Prerequisites

  • HTML document structure
  • Basic understanding of semantic HTML tags

Steps

  1. 1

    Set up the semantic skeleton

    Create accessible.html with the landmark elements: header, nav, main, and footer.

    Code
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <title>Accessible Page</title>
      </head>
      <body>
        <header></header>
        <nav></nav>
        <main></main>
        <footer></footer>
      </body>
    </html>

    Expected result

    An empty page with the four landmark elements in place.

  2. 2

    Fill the header and nav

    Add an h1 site title in the header and a nav list with 3 links. The h1 is the main heading — there should be only one per page.

    Code
    <header>
      <h1>My Accessible Site</h1>
    </header>
    <nav>
      <ul>
        <li><a href="#home">Home</a></li>
        <li><a href="#about">About</a></li>
        <li><a href="#contact">Contact</a></li>
      </ul>
    </nav>

    Expected result

    The header shows the site title and the nav shows 3 links.

  3. 3

    Add main content with image and form

    In main, add an h2, a paragraph, an image with descriptive alt text, and a labeled search input.

    Code
    <main>
      <h2>Welcome</h2>
      <p>This page is built with accessibility in mind.</p>
      <img src="https://placehold.co/400x200" alt="A placeholder showing a 400 by 200 pixel image">
      <form>
        <label for="search">Search the site</label>
        <input type="search" id="search" name="search">
        <button type="submit">Search</button>
      </form>
    </main>

    Expected result

    The main area shows a heading, paragraph, image, and a search form.

  4. 4

    Add the footer and minimal CSS

    Add a footer with a copyright line. Add a small style block for basic readability.

    Code
    <footer>
      <p>&copy; 2026 My Accessible Site</p>
    </footer>
    
    <style>
      body { font-family: system-ui, sans-serif; max-width: 40rem; margin: 0 auto; padding: 1rem; }
      nav ul { list-style: none; display: flex; gap: 1rem; padding: 0; }
      img { max-width: 100%; height: auto; }
    </style>

    Expected result

    A polished, accessible page with all landmarks, proper labels, and alt text.

  5. 5

    Add responsive styles

    Use media queries to adjust the layout for mobile: switch multi-column layouts to single column on small screens, reduce font sizes, and adjust spacing. Mobile-first means small-screen experience matters equally.

    Code
    @media (max-width: 640px) {
      .container {
        flex-direction: column;
        padding: 1rem;
      }
      h1 { font-size: 1.5rem; }
      .card { width: 100%; margin-bottom: 1rem; }
    }

    Expected result

    Below 640px viewport, the layout becomes single-column with smaller font and spacing; content does not overflow.

Try it yourself

What you learned

You built an accessible page with semantic landmarks, proper heading hierarchy, descriptive alt text, and associated labels — the foundation of web accessibility that benefits all users.

Related Resources

Related Lessons

Related Practice

Related Cheatsheets

Related Errors

Related Glossary

Related Glossary

A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.

Related Errors

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

← Back to topic