<search>

Term side of the Card.
Topic: Semantics
Unit title: <search>
Categories: Tag
Explanation side of the Card

Explanation: The element that represents a container for controls and content related to search or filtering purposes and can be used in various contexts, including the current webpage, a website or a document.

Browser compatibility:
  • The chrome browser supports this feature starting from version 118.
  • The edge browser supports this feature starting from version 118.
  • The firefox browser supports this feature starting from version 118.
  • The safari browser supports this feature starting from version 17.
Availability: 

Example

Wronghtml
<div class="search">
  <form action="/find">
    <input name="q">
  </form>
</div>
Righthtml
<search>
  <form action="/find">
    <label for="q">Search</label>
    <input id="q" type="search" name="q">
  </form>
</search>

<search> exposes a search landmark, and the label gives the input an accessible name.

Common mistakes

  • Putting search results inside <search> along with the form.
  • Still adding role="search" to a <search> element.

Key points

  • <search> wraps the search or filter form, not the search results.
  • The search input has a visible <label> or an accessible name.
  • The input uses type="search" inside the form.

Interview questions

Is <search> the same as <input type="search">?

No. <search> is a container landmark for the whole search area, while <input type="search"> is the text field.

What did people use before the <search> element?

A <form role="search"> or <div role="search">, which still works as a fallback.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy