# CSS Hamburger Menu: Icon, Animation and Accessible Toggle

DevFeed: [CSS Hamburger Menu: Icon, Animation and Accessible Toggle](<https://devfeed.tech/articles/css-hamburger-menu-icon-animation-and-accessible-toggle-105303.md>)

Original publisher: [Read original article](<https://markodenic.com/css-hamburger-menu/>)

Author: Marko

Published: 2026-10-28T09:00:00Z

Content type: tutorial

Language: en

Sources: [Marko Denic Blog](<https://devfeed.tech/sources/marko-denic-blog.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [aria](<https://devfeed.tech/topics/aria.md>), [web animation](<https://devfeed.tech/topics/web-animation.md>), [Responsive Design](<https://devfeed.tech/topics/responsive-design.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [Media Queries](<https://devfeed.tech/topics/media-queries.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [selectors](<https://devfeed.tech/topics/selectors.md>)

Tags: [accessible](<https://devfeed.tech/tags/accessible.md>), [animation](<https://devfeed.tech/tags/animation.md>), [aria](<https://devfeed.tech/tags/aria.md>), [breakpoint](<https://devfeed.tech/tags/breakpoint.md>), [button](<https://devfeed.tech/tags/button.md>), [css](<https://devfeed.tech/tags/css.md>), [desktop](<https://devfeed.tech/tags/desktop.md>), [flexbox](<https://devfeed.tech/tags/flexbox.md>), [gap](<https://devfeed.tech/tags/gap.md>), [grid](<https://devfeed.tech/tags/grid.md>), [html](<https://devfeed.tech/tags/html.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [keyboard](<https://devfeed.tech/tags/keyboard.md>), [max-width](<https://devfeed.tech/tags/max-width.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [motion](<https://devfeed.tech/tags/motion.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [toggle](<https://devfeed.tech/tags/toggle.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

## AI overview

A production hamburger menu should use a `<button>` whose `aria-expanded` state controls both the menu's visibility and the icon animation. Connect it to the menu with `aria-controls`, give it screen-reader text, hide decorative bars from assistive technology, and close the menu on Escape. CSS can draw the bars with three spans, which animate independently into an X, or with one element and pseudo-elements. A checkbox or `<details>` can provide a CSS-only toggle, but the excerpt says the button version announces state more clearly. On mobile, show the toggle and reveal the menu when expanded; on wide screens, show the links directly. The example also disables transitions when reduced motion is preferred.

## Source excerpt

Build a hamburger menu with CSS: the three-line icon, the animation to an X, a CSS-only toggle, the accessible button version with a few lines of JavaScript, and showing it only on mobile.