-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Consider allowing label elements to provide a label for landmark elements #5812
Comments
I don't think reusing label in this way is a good idea, but I appreciate the concrete problem description, separate from the jump to a specific solution. |
Alternate suggestions welcome and appreciated. I suppose |
Just commenting to add a bit of info here: FWIW, I do tend to agree that it would be nice to have a feature in HTML to allow for authors to name of landmarks that didn't rely on Often text within the landmark (such as a heading) would accurately serve as the landmark's name. A way to explicitly associate, say a heading with its container would be nice. But definitely something that would need an author to specifically do, not an automatic association. edit: ah. apparently took too long to type this, as Carolyn's comment came in before mine. |
Heading content as first child would be quite nice, from an author's perspective. But we'd have to make it really clear that there's magic behind the scenes, because this is really common: So I think we'd find that pages would suddenly - and probably unexpectedly - have a whole ton of new landmarks. That said, the fact that it would be so nice is compelling. I wonder if an attribute on a first-child-heading makes any sense, i.e. Hmmm... how about an attribute on the section or form? i.e.
Then I think it would be ok for ACCNAME to use the first-child-heading of a |
Right. this would be very bad. which is why, in my comment, i said:
|
<form>
<fieldset>
<legend>Choose your favorite monster</legend>
<input type="radio" id="kraken" name="monster">
<label for="kraken">Kraken</label><br/>
<input type="radio" id="sasquatch" name="monster">
<label for="sasquatch">Sasquatch</label><br/>
<input type="radio" id="mothman" name="monster">
<label for="mothman">Mothman</label>
</fieldset>
</form> |
Good point, @Yay295. Not sure if it makes sense to go with a whole new element ( |
I accidentally created a duplicate of this over in #7326, which has some good discussion. Trying to synthesize the two threads and summarize what I've learned so far...
|
If this is meant as a general solution:
For specific elements though, where these elements are already used and provide for a suitable accessible name, that seems OK to me. Some already do this: https://w3c.github.io/html-aam/#input-type-text-input-type-password-input-type-search-input-type-tel-input-type-url-and-textarea-element
This is also not always possible. In particular, Also, it doesn't always make sense to give an element an accessible name at all, and ARIA now prohibits it for some roles (like |
If, for the sake of having something tangible to use in examples, <nav>
<name hidden>the accessible name</name>
[...]
</nav> work even though it's As long as this is being solved once and for all, it would also be great if whatever the solution ends up as worked in all the other cases and you could use, say, |
@scottaohara responded to Domenic's questions in the now-closed issue, (before it was closed) which I am pasting here:
|
@jimmyfrasche the current accessible name computation algorithm (and for HTML) doesn't care about the One element type is not going to be able to cover all cases. For example, |
What about using the alt attribute like on images? |
i like the idea of having a new naming attribute that doesn't produce a tooltip like |
Certain HTML elements (main, nav, aside, header, footer, section, form) can have implicit ARIA landmark semantics.
Two of these - section and form - will only have implicit ARIA landmark semantics if they have an accessible name.
At present, the only way to give a section or form element an accessible name is to use either the
aria-label
oraria-labelledby
attribute.This is a problem if a user agent wants to include section and form elements in landmark navigation. User agents shouldn't have to rely on the presence or absence of ARIA markup to determine whether or not to include an element in a new behavior.
The label element can provide an accessible name to form controls like input, select, etc.
Consider allowing it to provide an accessible name for section and form elements as well, so that these elements can participate in landmark navigation.
Alternatively, consider allowing the label element to provide an accessible name for all of the landmark elements listed above. All of them are allowed to have an accessible name - it's only section and form that are required to have one in order to be considered landmarks. This would allow for something like:
The text was updated successfully, but these errors were encountered: