The icon with no name
A large practice site, one with dozens of guides, service pages and provider bios, benefits from a search box. Many are built as a thin text field with a magnifying glass icon, and sometimes an X that clears the text. To a sighted visitor the icons are plain. To a screen reader user, a button with no name is announced as button, and nothing more.
A patient who cannot find the insurance page through the menu may try search. If the box and its buttons are unnamed, that fallback fails for them.
What the sources say
The W3C Labels or Instructions page includes this very case. A website with a global search field in the header needs no instructions because any term can be entered, but the field needs a cue to communicate its purpose. Commonly the cue is a magnifying glass icon that serves as the visible label, often doubling as the search button.
The W3C Forms Tutorial shows the fix for the code side. A label can be hidden from view yet remain available to assistive technology, and its search example sits a text field beside a Search button. It also shows an accessible name on a button, applied through an attribute, and warns that this approach should be used only when the control's purpose is clear from the surrounding content, like that button. A title tooltip alone is called less reliable and not recommended.
The Name, Role, Value criterion requires a programmatically determinable name for all user interface components, and notes that names may be visible or invisible. An icon-only clear button is a user interface component, so it needs a name too, such as Clear search.
| Part of the search | What it needs |
|---|---|
| Text box | A label in the code, hidden from view only if the button beside it makes the purpose obvious |
| Search button with a magnifying glass icon | The name Search |
| Clear button shown as an X | The name Clear search |
| Results page heading | Words such as Search results, so a screen reader user knows the search ran |
| No results message | A sentence that suggests another route, as in our guide to site search and 404 pages |
Two details that cause trouble
- Button words and picture should match. If the button shows the word Search, its spoken name should contain the same word, so a patient who uses voice control can say it.
- A placeholder such as Search our site is not a label. The tutorial states that placeholder text is not a replacement for labels, which our guide to visible labels explains.
Keep search words private
Patients type worries into search boxes. Check that your analytics setup does not send what they type to an ad platform. Our guide to Google Tag Manager without sending patient data covers what to exclude.
A five-minute test
- 1Open your site with a screen reader on, as in our five-minute screen reader test.
- 2Tab to the search area. Listen for a name before the text box, and a name for each button.
- 3Type a word and search. Check that the results page announces itself.
- 4Type text, then tab to the clear control. It should say what it does.
- 5Check the menu icons too, with our guide to phone and menu icon buttons.
We do not give legal advice, and naming search controls does not by itself make a site conform to any standard.
Frequently asked questions
Does a small site need a search box?
Often not. A short, clear menu and a visible phone number serve a small practice site better. A search box earns its place on a site with many guides and pages.
Can I rely on the magnifying glass as the label?
The W3C accepts a magnifying glass as a visible cue for a search field, especially when it is also the search button. The code still needs a name for the button so a screen reader announces it.
Is a tooltip enough to name a button?
The W3C Forms Tutorial calls the title attribute less reliable and not recommended, because some assistive technologies do not treat it as a name. Use a proper name in the code.
Who should name the buttons?
Your web designer, or the search plugin settings if there are any. Send one line: every icon button in the search box needs a short spoken name such as Search and Clear search.
How do I check that it worked?
Repeat the screen reader test after the change. If each control is announced with a name, it worked. Write the date of the check in your page inventory.
Sources
- W3C Web Accessibility Initiative — Understanding Success Criterion 3.3.2: Labels or Instructions
- W3C Web Accessibility Initiative — Forms Tutorial: Labeling Controls
- W3C Web Accessibility Initiative — Understanding Success Criterion 4.1.2: Name, Role, Value