A webpage should make sense even when someone cannot see its colors, pictures, or layout.
What You Need to Know
A search form needs a clear name for its search field and a way to submit. Search results should then have meaningful headings and links so visitors can browse them quickly.
Try the Example
Take a look at the example. We’ll explain the important lines right below it.
<search>
<form action="/search" method="get">
<label for="site-query">Search lessons</label>
<input id="site-query" type="search" name="query" required>
<button type="submit">Search</button>
</form>
</search>
<main><h1>Search results</h1><p>Three lessons matched your query.</p></main>
Let’s Read the Code
- <form>: The form groups controls and identifies where submitted data goes.
- <label>: The label tells people what the input is for. A matching for/id pair makes the label clickable.
- for: For connects a label or output with a control by ID.
- id: An id uniquely identifies an element on this page.
What the example shows: The search landmark identifies the search controls; the main region contains the returned results.
What Happens in the Browser?
Try this with Tab and Shift+Tab. If you can, inspect the accessibility tree too; appearance alone does not tell the whole story.
Try a different way of reading. Read only the headings and labels, or navigate through links without looking at the rest of the page. If the page still makes sense, the underlying HTML is probably doing an important part of its job.
Your Turn
Try to locate the search form and the results as separate areas with a screen reader.
Common Beginner Mistakes
- Judging the page only by how it looks, without checking its meaning and keyboard behavior.
- HTML does not search a database by itself—the search endpoint supplies actual results.
Key Takeaways
- A search form needs a clear name for its search field and a way to submit.
- <form>: The form groups controls and identifies where submitted data goes.
- A meaningful HTML element is usually a stronger starting point than adding an ARIA role to a generic div. Also check what happens using only the keyboard.