CSS Button Generator
Design CSS buttons visually for free — set colours or a gradient, padding, corner radius, border, shadow, font and letter spacing, pick a hover effect (darken, lift, fill, press or glow), and copy clean CSS and HTML. Six presets to start from, with hover, active and keyboard-focus states included.
100% private — everything runs in your browser. Conversion happens on your device; nothing is uploaded.
How to create a CSS button
- Start from a preset, or set your own colours.
- Adjust size, padding, radius, border and shadow.
- Choose a hover effect and hover over the preview to test it.
- Copy the CSS and HTML into your project.
What you can use it for
- Create call-to-action buttons for landing pages
- Match buttons to your brand colours
- Prototype button styles for a design system
- Learn how hover and focus states are written in CSS
More free tools
Building for the web?
Format, minify, convert and generate code with our free, private developer tools.
See all free tools →Frequently asked questions
How do I use the generated CSS?
Paste the CSS into your stylesheet and add class="btn" to any link or button. Rename .btn if it clashes with an existing class.
Does it work on <button> elements?
Yes. The CSS works on both <a> and <button> elements — for a <button>, replace the link tag in the HTML.
Is the button accessible?
The code includes a visible keyboard-focus outline. Keep strong contrast between text and background — check it with our Contrast Checker.
Can I make a gradient button?
Yes — tick Gradient and the background blends from the first colour to the second. Try the Gradient preset.
Is the code free to use?
Yes, for personal and commercial projects.
What does each hover effect do?
Darken switches the background to your Hover / 2nd colour, or slightly dims a gradient. Lift raises the button 2px and gives it a bigger shadow. Fill swaps in the second colour with white text, which suits outline buttons. Press nudges it 2px down and to the right and shrinks the shadow, which pairs well with the Hard (retro) shadow. Glow adds a 4px ring in your background colour at 30% opacity. Each change eases in over 0.15 seconds.
How do I make an outline (ghost) button?
Click the Outline preset. It gives the button a white background, a 2px blue border and blue text, with the Fill hover effect, so on hover the button fills with your Hover / 2nd colour and the text turns white. To use your own colour, change Text colour, Border colour and Hover / 2nd colour to match. Set Border width to 0 if you want to remove the outline again.
Which size, padding and corner settings can I change?
Font size runs from 11 to 32px and weight from 400 to 800. Horizontal padding goes from 6 to 60px, vertical padding from 4 to 30px, corner radius from 0 to 100px (100 gives a pill shape) and border width from 0 to 6px. You can also set letter spacing up to 0.2em, pick one of five shadow options or five font stacks, and tick Uppercase or Full width. Button text can be up to 40 characters.
How do I use more than one button style on the same page?
Design the first style, copy the CSS, then rename .btn to something like .btn-primary. The name appears in four rules: the button itself, :hover, :active and :focus-visible, so change all four, or use find and replace. Repeat for each style, such as .btn-outline, and give each link or button its matching class. The tool keeps one design at a time, so copy each style before starting the next.
Why is my full-width button wider than its container?
Full width sets the button to display: block and width: 100%, and the padding and border are added on top of that width unless your stylesheet already uses border-box sizing. If the button spills past the edge, add box-sizing: border-box; to the .btn rule so the padding and border stay inside the 100%. The preview here already uses border-box sizing, which is why it looks right in the tool.
How do I link the button to a page?
The HTML is a link with href="#" as a placeholder, so the button goes nowhere until you change it. Replace the # with the page you want, such as /contact/ or a full https:// address. The text inside the link is whatever you typed in Button text, so you can also edit the wording straight in your HTML later without touching the CSS.
Do I need to give credit, and do the fonts need a licence?
No credit or link back is needed: the CSS and HTML are yours to use in personal, client and commercial work, including templates you sell. The code doesn't include or load any font files. It only lists font names such as system-ui, Arial, Georgia or Trebuchet MS, ending in a generic fallback like sans-serif, and the browser uses what is on the visitor's device. If you swap in a web font, check that font's own licence.