<search>
Example
<div class="search">
<form action="/find">
<input name="q">
</form>
</div><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">?
<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?
<search> element?A <form role="search"> or <div role="search">, which still works as a fallback.