Free visual CSS tool

CSS Dropdown Menu Generator

Design a real click-to-open dropdown menu. Style the trigger and panel, pick your items, then copy working HTML, CSS and JavaScript — try it live below, it actually opens and closes.

Click the trigger to try it — it really opens
HTML + CSS + JS

A dropdown that actually works, not just a mockup

Most CSS dropdown snippets only show a static screenshot. This one is a live, functional button and menu right in the page — open it, click an item, click away, or press Escape.

Real open/close logic

Click, outside-click and Escape are wired up with genuine vanilla JavaScript, not CSS-only hover tricks.

Three menu styles

Flat white, shadowed, or a frosted glass panel — pick the look that matches your UI.

Copy one clean block

Get the HTML, CSS and the small JS toggle script together, ready to paste into any project.

How to build a CSS dropdown menu

  1. Set the trigger and itemsType the button label, then list each menu item as an icon glyph and a label separated by a pipe.
  2. Style the panelChoose flat, shadowed or glass, tune the corner radius and hover color, then pick where the menu should open.
  3. Test and copyClick the live trigger to confirm it opens and closes correctly, then hit Copy code for the full HTML, CSS and JS.

About building dropdown menus with CSS and JS

A dropdown menu looks simple but has a few details that make or break it: the panel needs to be positioned relative to its trigger without shifting layout, it needs a smooth open and close transition, and it must close itself when a user clicks elsewhere or presses Escape for accessibility. This generator builds all of that for you with a small, dependency-free JavaScript toggle and CSS that handles the visual states. Because the trigger is a real button with aria-haspopup and aria-expanded attributes that update on open and close, screen readers and keyboard users get sensible behavior out of the box, and you can extend it with arrow-key navigation later if you need a full menu widget.

Click vs. hover

This generator uses click-to-open rather than hover, which works better on touch devices and avoids menus that flicker open by accident.

Outside-click detection

A single document-level click listener checks whether the click landed outside the menu wrapper and closes it if so.

Positioning without JS math

The menu is absolutely positioned relative to the trigger using plain CSS, so no runtime position calculation is needed.

Keyboard friendly

Escape closes the open menu from anywhere on the page, a baseline expectation for accessible dropdown components.

CSS dropdown menu generator FAQ

Does this dropdown menu actually open and close?

Yes. The live preview is a fully working dropdown: click the trigger to open it, click an item or anywhere outside to close it, or press Escape.

What code do I get when I click Copy?

You get one combined block containing the trigger button and menu HTML, the CSS for your chosen style, radius and colors, and the small vanilla JavaScript snippet that opens, closes and handles outside clicks and Escape.

Can I use my own icons instead of the glyphs?

Yes. Each menu line uses the format "glyph | label". Replace the glyph with any character, emoji, or leave it blank, or swap the span for your own icon markup after copying.

Does the generated menu work without any JavaScript framework?

Yes. The copied script is plain vanilla JavaScript with no dependencies, so it drops straight into any HTML page or component.

Try other navigation tools

Keep building your site navigation with these free generators.