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
Unclear which legend element to be used as accessible name for fieldset #145
Comments
Good question! In this context I think it would be the child of the element in question (a heading inside a legend element for example), where it is the content of the child element that becomes the accessible name for the grandparent.
Continuing with legend as an example... If the legend element has no children, the text content of the legend becomes the accessible name for the fieldset. If there is no legend element inside the fieldset, the fieldset does not have an acessible name (unless it's been provided using ARIA).
If the legend element has multiple conforming children, the combined text content inside those children would become the accessible name for the fieldset. I haven't tested this extensively though (because it isn't a pattern seen in the wild beyond span elements AFAIK). If there are multiple legend elements inside the fieldset, only the first is used as the accessible name for the fieldset.
I'm not sure about the shadow DOM boundary, but a brief experiment suggests that inserting an element with Another quick experiment suggests that putting
If |
How did you experiment? I tested in Firefox and Chrome on macOS, using their accessibility tree view in developer tools, with this test case. http://software.hixie.ch/utilities/js/live-dom-viewer/saved/6165 In both browsers, the fieldset is represented as a "group" node with accessible name "The legend" for the first fieldset, and a "group" node with accessible name "" for the second fieldset, which suggests that there is a difference.
The spec doesn't say so AFAICT, and at least in Firefox, for this test case http://software.hixie.ch/utilities/js/live-dom-viewer/saved/6166 the "group" node still has the accessible name "The legend". (In Chrome it is "".) |
For this test Both Firefox and Chrome have empty accessible name for the "group" node in the accessibility tree. |
Based on the above, I propose that the accessible name algorithm use the same logic as how it's defined semantically in the HTML standard:
https://html.spec.whatwg.org/multipage/form-elements.html#the-fieldset-element Separately, on the difference for Edge seems to not give the fieldset an accessible name at all, unless you use |
What is the legend subtree?
Similarly for figure/figcaption, table/caption.
Cases to consider:
display: contents
element in between, or if it crosses a shadow DOM boundary).display: none
).The text was updated successfully, but these errors were encountered: