CSS Button Generator
WM-111Set the colors, padding, border, corner radius and font and get a button rule with a hover style and a keyboard focus outline, plus the matching HTML.
Runs in your browser. Nothing is uploaded.
Button
Preview and CSS
| Button HTML | <button type="button" class="button">Get started</button> |
|---|---|
| Hover color | #4338ca |
| Font | System UI |
CSS
.button {
display: inline-block;
padding: 12px 24px;
border: none;
border-radius: 8px;
background-color: #4f46e5;
color: #ffffff;
font: 600 16px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
cursor: pointer;
transition: background-color 0.15s ease;
}
.button:hover {
background-color: #4338ca;
}
.button:focus-visible {
outline: 2px solid #4f46e5;
outline-offset: 2px;
} How to use it
- Type your button label. It shows in the preview and goes into the HTML line.
- Pick the background, text and hover colors, then set padding, border and radius.
- Choose a font, weight, text case and shadow.
- Use Preview shows to look at the hover state, then press Copy.
What the CSS includes
The output has a .button rule with display, padding, border, radius, colors, font, an optional shadow, a pointer cursor and a short background transition. A :hover rule sets the hover background, and a :focus-visible rule adds an outline so keyboard users can see where they are. Fonts are system font stacks, so no font file is downloaded.
What the preview shows and does not show
The preview draws the button from the same CSS with your label inside it, so padding, colors, border, radius, shadow and text are all real. The font is a system font stack, so the exact letters depend on the visitor's device. The Preview shows setting only changes the preview and never the CSS. Gradients and animations are not part of this generator.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Enter a button label. | The label field is empty. | Type the text the button will show. |
The button label must be 60 characters or fewer. | The label is longer than the limit. | Shorten it to 60 characters or fewer. |
Questions people ask
How do I add a hover effect to a CSS button?
Add a :hover rule that changes the background color. This generator writes one for you from the Hover background field, and the base rule has a short transition so the change fades instead of jumping.
Should I use a button element or a link?
Use a button element for actions on the page, such as submitting a form, and a link for going to another page. The same CSS works on both if you apply the class.
Why does my button text look slightly different on another computer?
The generator uses system font stacks, so each device draws the label in its own built-in font. Nothing is downloaded, and the size, weight and color stay the same.
Is the label safe to paste into HTML?
Yes. Characters such as less-than, ampersand and quotes in the label are escaped in the HTML line, so a label cannot break out of the button element.
How do I make the button larger?
Raise the font size and the padding. Padding sets the space around the label, so more horizontal padding gives a wider button and more vertical padding gives a taller one.
Why is a focus outline included?
Keyboard users need to see which control is selected. The :focus-visible rule shows an outline only for keyboard focus, so mouse clicks do not show it.
About this tool
Builds a .button rule, a :hover rule with the hover background and a :focus-visible outline so keyboard users can see focus. Fonts are system font stacks only, so nothing is downloaded. The preview draws the button from the same CSS with your label inside it, using a system font stack, so the final look depends on the fonts each device has. The Preview shows setting only changes the preview. Your label is HTML-escaped in the HTML line. Gradients and animations are not included.