HTML: input type="search"
The search input is a text field intended for search queries and may provide a clear button or search-friendly behavior in the browser.
What you will learn
- How to label and submit a search field
- How search differs from ordinary text input
- How to preserve keyboard and assistive-technology access
Minimal example
<form action="/search" method="get">
<label for="site-search">Search this site</label>
<input id="site-search" name="q" type="search">
<button type="submit">Search</button>
</form>The input type communicates the purpose to browsers and assistive technology. The actual search behavior still comes from your form action or JavaScript.
Common mistakes
- Do not remove the label just because a magnifying-glass icon is visible.
- Do not assume every browser shows the same clear button or styling.
- Validate and safely handle the query on the server; escape it when displaying results.