- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <search> Tag
HTML Tags
HTML <search> Tag
Learn how the HTML <search> tag semantically identifies controls and content used for searching or filtering.
The search tag wraps a search box or a set of filters. It looks like nothing on its own, but it tells screen readers "this is where you search", so they can jump straight to it.
<search> is one of the newest HTML elements, added in 2023. Before it, the same meaning needed <form role="search">. It does not search anything by itself; the form or script inside does the work.
Syntax
html
<search>
<form action="/search">
<label for="query">Search:</label>
<input type="search" id="query" name="q">
<button type="submit">Search</button>
</form>
</search>| Attribute | What it does |
|---|---|
| aria-label | A name for the search area, useful when a page has more than one, such as "Site search" and "Filter products". |
The global attributes such as class and id also work.
Example
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search Tag Example</title>
<style>
search {
display: block;
max-width: 520px;
padding: 20px;
border: 1px solid #d7e2e5;
border-radius: 10px;
background-color: #f7fbfc;
}
search form {
display: flex;
align-items: end;
gap: 10px;
}
search label {
display: grid;
flex: 1;
gap: 6px;
font-weight: bold;
}
search input,
search button {
padding: 10px 12px;
border-radius: 6px;
}
search input {
border: 1px solid #9fb2b8;
}
search button {
border: 0;
background-color: #29AB87;
color: white;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Search Our Tutorials</h1>
<search aria-label="Tutorial search">
<form action="/search">
<label for="tutorial-query">
Search tutorials
<input
type="search"
id="tutorial-query"
name="q"
placeholder="Enter HTML, CSS, or JavaScript"
>
</label>
<button type="submit">Search</button>
</form>
</search>
</body>
</html>A styled box with a labelled search field and a button. To a screen reader, the box is announced as a search landmark called "Tutorial search".
Where to use it
- Around the main site search box, usually in the header.
- Around filters that narrow down a list, like price and color filters on a product page, even without a form.
Do not put the search results inside <search>. The results are the page's main content.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | No |
In browsers that do not know <search> yet, it simply acts like a <div>, so nothing breaks. For older screen reader support, some sites still add role="search" to it.
HTML <search> Tag exercises
Mark a search region
Make the element that marks the search part of a page. It holds a form with a search field named q.
Result
