Search
A search form in a <search> landmark with an <input type="search">.
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 value | Effect |
|---|---|
<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
| Key | Action |
|---|---|
| Enter | in the field, submits the search |
| Esc | in the field, clears it (in browsers that support it) |
| Tab | moves 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
- Molecules
- Search dialog: jump to a page or section from anywhere, with Cmd-K or Ctrl-K
- Source:
css/components/molecules/search.css,examples/molecules/search.html
How other systems do it
For comparison only; these are not the standard this system follows.