Interactive HTML Trees with No JavaScript
shkspr.mobi
shkspr.mobi
So screen readers which rely on these semantics could cause confusing behaviour.
Yes, and it reads leaves as collapsed, the user expands them and there's nothing there. That's confusing.
> The alternative of using some show/hide element with an onClick handler probably doesn't work as well for screen readers without a bunch of aria tags.
Yeah, `aria-expanded` (you need an expanded CSS class anyway) and maybe `aria-owns`. Titanic work.
The cool thing about accessibility is that you have to think a lot less. You just open https://www.w3.org/TR/wai-aria-practices-1.1 , find the widget or scenario you need and do as they say. Win-win.
However, for accessibility reasons, Son of Suckerfish[0] works a bit better. It moves hidden items out of the viewport instead of using display: none, thus making the menu usable to screenreaders users without them having to "hover". It would of course also be advisable, to expand the :hover to also inlclude :focus.
> WARNING! This is a misuse of these HTML elements. While it is valid markup, it may not be accessible. This is an experiment and not intended for production use.
Could even default the details to shown with the "open" attribute and still meet the spec-detailed description as the affordance there is that it can then be hidden.
DETAILS spec: https://html.spec.whatwg.org/multipage/interactive-elements....
It's not nested but I'm sure it could be made to look just as good if it was.
Edit: That link you gave looks pretty nice though, I'm actually in need of a tree view today, I might try that.
The `:checked` stuff also works great for accordions and whatever else is toggled, I use it all the time.