Skip to Content
Component ExamplesSearch Input

Search Input

Search fields with live results, the search landmark, and autocomplete search.

Maintained by Martin KrugerLast reviewed

Overview

Search is one of the most common ways users find content on a site, yet search inputs are frequently inaccessible. A search field without a label forces screen reader users to guess its purpose. Without a search landmark, users cannot jump directly to the search form. And when live results appear dynamically, screen reader users are never told that results have loaded unless a live region announces the change.

WCAG Criteria:

Key requirements:

  • Every search input must have a visible or visually-hidden <label>
  • Wrap the search form in a <search> element (or <form role="search">) to create a search landmark
  • Use type="search" on the input for native clear button and semantics
  • Announce live result counts with role="status" so screen readers report changes without moving focus
  • Debounce live result announcements to avoid overwhelming screen reader users with rapid-fire updates

Search Field

Unlabeled Search vs. Accessible Search with Live Region

Inaccessible

5 results found

  • Getting started guide
  • API reference
  • Search best practices
View inaccessible code
<!-- No label, no landmark, no live region --> <div> <div class="search-box"> <svg><!-- magnifying glass icon --></svg> <input type="text" placeholder="Search..." /> </div> <div class="results"> <p>5 results found</p> <ul> <li>Getting started guide</li> <li>API reference</li> </ul> </div> </div>
Accessible

5 results found

  • Getting started guide
  • API reference
  • Search best practices
View accessible code
<search> <form role="search"> <svg aria-hidden="true"><!-- icon --></svg> <label for="search-good-input" class="sr-only"> Search </label> <input id="search-good-input" type="search" placeholder="Search..." /> </form> <div class="results"> <p role="status">5 results found</p> <ul> <li>Getting started guide</li> <li>API reference</li> </ul> </div> </search> <style> .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; } </style>

What’s wrong with the unlabeled search?

  • The input has no <label> — a screen reader announces only “edit text” with no indication this is a search field
  • The magnifying glass SVG is decorative but not hidden with aria-hidden="true", potentially creating confusing announcements
  • The container is a plain <div>, not a search landmark — users cannot jump to it via landmark navigation
  • When results load dynamically, the “5 results found” text is never announced to screen reader users
  • type="text" instead of type="search" loses the native clear button and search semantics

Predicted semantic summary (exact output varies):

VersionAnnouncement
Inaccessible (no label)“edit text” — no context that this is search
Accessible (labeled + landmark)“search landmark, Search, search text” — full context
Results update (no live region)Nothing — user must manually navigate to see results
Results update (with role="status")“5 results found” — announced automatically

Use a result-count status only when the count changes without an obvious focus or page transition. Debounce rapid filtering, update the same pre-existing text-only status node, and avoid duplicating the message in another live region. A search results heading remains useful for navigation even when a short status message is provided.


Resources