Screen reader users jump between landmarks like the navigation, the main content and the search. HTML now has an element that marks the search part without an ARIA role. I’d pick it over the ARIA role for new pages.
Wrap the search or filter controls in <search>:
<header>
<h1>Movie website</h1>
<search>
<form action="/search/">
<label for="movie">Find a movie</label>
<input type="search" id="movie" name="q">
<button type="submit">Search</button>
</form>
</search>
</header>
The element has the implicit ARIA role search, so it creates a search landmark. Before this you wrote <form role="search">. The old pattern still works, and the MDN page does not call it wrong, but the new element is clearer, and it also fits things that are not a form, such as a live filter on a table or a list.
Caveats:
- It is for the search or filter controls, not the results. Results belong in the main content. Quick suggestions that appear while typing can sit inside it.
- It has no look of its own, so you get no visual change and need your own CSS.
- It has been available since October 2023. Older browsers and assistive tools may not map it to a landmark, so some people keep
role="search"on the form as a belt-and-braces measure. - Use it once per page for the main search. Several landmarks with the same role are confusing unless you label each with
aria-label.
It is a small change, but it costs nothing and helps people who navigate by landmark.
Further reading: MDN: <search>
Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get