domestic-ui GitHub

Search

A search form in a <search> landmark with an <input type="search">.

Where search is used Site search sits in the app bar as a search input with a Search button; a labelled search form can also head a page of results.

Live example

With a visible label

<search aria-label="Guides">
  <form action="search.html" method="get">
    <label for="guide-search">Search the guides</label>
    <input id="guide-search" type="search" name="q" autocomplete="off" aria-describedby="guide-search-hint">
    <button type="submit">Search</button>
    <p id="guide-search-hint" data-field-hint>Try "tokens" or "dialog".</p>
  </form>
</search>

Compact, label visually hidden

<search aria-label="Site">
  <form action="search.html" method="get">
    <label for="site-search" class="visually-hidden">Search this site</label>
    <input id="site-search" type="search" name="q" autocomplete="off">
    <button type="submit" data-button="secondary">Search</button>
  </form>
</search>

Attributes

Attribute or valueEffect
<search> > <form> with an <input type="search">no attribute needed: the label and any hint span the full width, the input and the submit button share the row below.

Keyboard

KeyAction
Enterin the field, submits the search
Escin the field, clears it (in browsers that support it)
Tabmoves from the field to the button

Accessibility

  • <search> is a landmark. Label it only when there are several.
  • The input needs a <label>, visually hidden if space is short. A placeholder is not a label (WCAG 3.3.2).

Specifications

See also

How other systems do it

For comparison only; these are not the standard this system follows.

Search