DEV Community

Discussion on: How to make menus with CSS—no JavaScript or Bootstrap required!

Collapse
 
leewarrickjr profile image
Lee Warrick

True, however aside from the input checkbox trick, the rest of the CSS is fine as far as accessibility.

You'd be better off using JS for the toggling, and with the popularity of JS frameworks, you're likely to not have a silly restraint like "no JS allowed".

But since I had to do this as coding challenge, I figured it was worth sharing.

Collapse
 
angeliquejw profile image
Angelique

Admittedly, I have only looked at the code and not tested this with a screenreader, but I think you're overestimating the accessibility of this markup and CSS. Without JS, there's no changing of ARIA attributes alerting a screenreader user to these interactive elements, the checkbox input isn't labeled, you're treating items that usually don't get focus (like span) as interactive elements, there are no :focus styles, etc.

I know accessibility wasn't the focus of this exercise, but it's not even mentioned in your caveats or things folks get when they add in JS. While I 💯 agree with your closing sentiment, I'm too cognizant that, for some, mastery of CSS is all about trickery and challenges and not functionality and usability.