https://www.pausly.app/blog/accessible-hamburger-buttons-without-javascript [ ] Open menu Close menu * Home * Blog * FAQ Login A diagram of a hamburger button that changes from it's original hamburger form to a close symbol. The elements are arranged in a way that makes it look like a smiley. Accessible hamburger buttons without JavaScript Friday, January 27th, 2023, 13:45 Over the last few decades hamburger buttons have become the de facto standard to expand larger menus on smaller devices. They are so ubiquitous that every user immediately knows what they are when seen in the top left or right corner, which makes them a good user interface element choice. They are also very easy to implement with JavaScript: listen to the onclick event of the button and add or remove a class so you can style the menu with CSS accordingly. So, if it's that easy to do, why bother with a HTML and CSS only solution? Well, there are two reasons. Firstly, people can't load or execute the JavaScript on your page more often than you think ( everyone has JavaScript, right?). But more importantly, it is very likely that your user sees a SSR (server side rendered) page served as pure HTML initially, before the JavaScript is loaded. On SSR pages you want your navigation to work immediately - before any JavaScript is loaded. I'm sure you've experienced it before. You navigated to a site, it seems to have fully loaded, and you press the hamburger button... but nothing happens. You do that again and again until finally the JavaScript finishes loading in the background and the menu opens. Even if you don't care about the few people that sometimes aren't able to execute the JavaScript on your site (which... you probably should) there is good reason to create a hamburger button without JavaScript anyway and remove that frustration. The hamburger button on this site is built with the exact same technique described in this article. Make sure your browser window is small enough so you can see it, and try it! The basics We will be adding some additional elements later on to make sure the site remains accessible for people using screen readers, but the core concept to create a pure HTML & CSS hamburger button is quite easy. It consists of these elements: * An (invisible) checkbox above the HTML of our menu with the menustate id * A