CSS Button Generator

Create a styled button and copy its CSS, including the hover state.

Loading tool...

How to use CSS Button Generator

  1. Choose the background and text colors.
  2. Adjust padding, radius and font size.
  3. Copy the CSS.

About this tool

The generated rule styles a .btn class with padding, rounded corners and a transition, plus a :hover rule that darkens the background. Keep a clear focus style as well so keyboard users can see which button is selected.

Make sure the text and background colors have enough contrast. You can check them with the contrast checker.

Frequently Asked Questions

How big should a button be?
At least 44 by 44 pixels is recommended for touch targets.
How do I add an icon?
Place the icon inside the button element and give the button display: inline-flex with a gap.

Related tools