{"id":316692,"date":"2020-07-14T07:38:10","date_gmt":"2020-07-14T14:38:10","guid":{"rendered":"https:\/\/css-tricks.com\/?p=316692"},"modified":"2020-07-14T07:38:11","modified_gmt":"2020-07-14T14:38:11","slug":"three-css-alternatives-to-javascript-navigation","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/three-css-alternatives-to-javascript-navigation\/","title":{"rendered":"Three CSS Alternatives to JavaScript Navigation"},"content":{"rendered":"\n
Hey quick! You\u2019ve gotta create the navigation for the site and you start working on the mobile behavior. What pattern do you choose? If you\u2019re like most folks, it\u2019s probably the \u201chamburger\u201d menu that, when clicked, uses a little JavaScript to expand a vertical list of navigation links.<\/p>\n\n\n\n
But that\u2019s not the only<\/em> option.<\/p>\n\n\n\n Depending on the context and contents of the navigation, there may be a JavaScript-free method that gets the job done while providing a more accessible experience.<\/p>\n\n\n\n\n\n\n\n It is considered best practice to use a progressive enhancement approach, building webpages for users with the oldest and least capable technology first, then introducing additional enhancements as support allows. If you can provide a quality experience for users with basic technology, then you might consider whether or not your webpage even requires JavaScript functionality at all. Leaving JavaScript out of the navigation can ensure that users are able to navigate your website even if JavaScript is disabled or network issues prevent scripts from loading \u2014 which are definitely wins.<\/p>\n\n\n\n Let\u2019s look at three alternative patterns to the JavaScript-powered hamburger menu.<\/p>\n\n\n Who said navigation has to be in the header of every page? If your front end is extremely lightweight or if you have a long list of menu items to display in your navigation, the most practical method might be to create a separate page to list them all. The lightweight WordPress theme Susty<\/a> utilizes this method for its navigation.<\/p>\n\n\n\nAlternative 1: Put the menu on a separate page<\/h3>\n\n\n