-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Prefer <search> over role="search" #41439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
files/en-us/learn_web_development/core/accessibility/wai-aria_basics/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/accessibility/aria/reference/roles/search_role/index.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable with the caveat that we should recommend search first (after all, that's the title) and this focusses on the role first. I understand the reasoning (depth of support) but that will become less significant over time, and I'm not particularly worried about relative terseness.
I think terseness is a big factor when judging two pieces of code that do the same thing. Someone telling me "prefer A over B" doesn't really matter, even if that someone is WAI, if there's no tangible reason for me as a developer or for my users. Also |
I'm a bit meh. I'd probably just use the search element because its purpose is clear and obvious. But either way, sure, you're the author. Still worth wording search first. |
Yeah just did |
files/en-us/web/accessibility/aria/reference/roles/landmark_role/index.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Josh-Cena Nice. I'd quite like a review from @scottohara or @estelle too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few nits....
files/en-us/web/accessibility/aria/reference/roles/landmark_role/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/accessibility/aria/reference/roles/search_role/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/accessibility/aria/reference/roles/search_role/index.md
Outdated
Show resolved
Hide resolved
This could, however, cause confusion for screen reader users, since they will not have any verbal indication of what the search input is. One way around this that won't impact on your visual design is to use [landmark elements](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/landmark_role). | ||
|
||
- A `role` attribute of value `search` on the `<form>` element will cause screen readers to announce that the form is a search form. | ||
- Wrap the whole search functionality in a {{HTMLElement("search")}} element, which creates a landmark region that assistive technologies can announce and quickly navigate to. If your `<input>` is already in a `<form>`, you can alternatively add [`role="search"`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/search_role) to the `<form>` element, which also makes the `<form>` a search landmark. The `<search>` element uses native HTML semantics, while `role="search"` has more support and may be terser to type if you already have a `<form>` wrapper. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Wrap the whole search functionality in a {{HTMLElement("search")}} element, which creates a landmark region that assistive technologies can announce and quickly navigate to. If your `<input>` is already in a `<form>`, you can alternatively add [`role="search"`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/search_role) to the `<form>` element, which also makes the `<form>` a search landmark. The `<search>` element uses native HTML semantics, while `role="search"` has more support and may be terser to type if you already have a `<form>` wrapper. | |
- Wrap the whole search functionality in a {{HTMLElement("search")}} element, which creates a landmark region that assistive technologies can announce and quickly navigate to. If your `<input>` is already in a `<form>`, you can alternatively add [`role="search"`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/search_role) to the `<form>` element, which also makes the `<form>` a search landmark. The `<search>` element uses native HTML semantics, while `role="search"` is well supported and may be terser to type if you already have a `<form>` wrapper. |
To future-proof, since they may soon be equally well supported (if not already the case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While they can both be "well-supported", it is always the case that role="search"
has "more support". Whenever we talk about AT, old browsers and ATs are still relevant.
f69bdc6
to
5b38ddd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 🎉
Fix #37799