Skip to content
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

Revisit the use of the hidden attribute in Accordion #40

Closed
charlie-yao opened this issue Dec 15, 2021 · 3 comments · Fixed by #43
Closed

Revisit the use of the hidden attribute in Accordion #40

charlie-yao opened this issue Dec 15, 2021 · 3 comments · Fixed by #43
Projects

Comments

@charlie-yao
Copy link
Owner

In the example of the Accordion widget, they use the hidden attribute to hide a collapsed accordion section. Their tabs example also uses the hidden attribute.

https://www.w3.org/TR/wai-aria-practices-1.1/examples/accordion/accordion.html
https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html

However, some argue that using CSS (i.e. display: none) is more appropriate, and the tabs widget is directly referenced as an example of where hidden should NOT be used!

https://stackoverflow.com/questions/6708247/what-is-the-difference-between-the-hidden-attribute-html5-and-the-displaynone
https://html.spec.whatwg.org/#the-hidden-attribute

But IME, screen readers ignore display: none as well! Maybe there's a difference between what gets put on the accessibility tree... must investigate.

@charlie-yao charlie-yao added this to To do in Design Patterns and Widgets via automation Dec 15, 2021
@charlie-yao
Copy link
Owner Author

charlie-yao commented Dec 15, 2021

My current opinion: don't use the hidden attribute. I can't help but agree with the argument:

The hidden attribute must not be used to hide content that could legitimately be shown in another presentation. For example, it is incorrect to use hidden to hide panels in a tabbed dialog, because the tabbed interface is merely a kind of overflow presentation — one could equally well just show all the form controls in one big page with a scrollbar. It is similarly incorrect to use this attribute to hide content just from one presentation — if something is marked hidden, it is hidden from all presentations, including, for instance, screen readers.

And, it feels better to follow the HTML spec. The examples used are "merely" example implementations... right? Bleh.

Since it seems like display: none is treated the same as hidden by screen readers and browsers, I think I'm just going to go with a visual-hide technique:

https://webaim.org/techniques/css/invisiblecontent/

@charlie-yao
Copy link
Owner Author

Some more discussion:

w3c/aria-practices#601
whatwg/html#4904

@charlie-yao
Copy link
Owner Author

Note: ultimately decided to go with display: none;.

Design Patterns and Widgets automation moved this from To do to Done Feb 22, 2022
@charlie-yao charlie-yao added this to To do in Accordion via automation Sep 13, 2022
@charlie-yao charlie-yao moved this from To do to Done in Accordion Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

1 participant