← All tools/Generators/Design/CSS Button Generator

CSS Button Generator

Style a button, preview it live and copy the CSS and HTML.

px
px
px
px
px

Hover over the preview button to see the hover colour in action.

Live preview

CSS code

HTML code

How it works

.btn {
  background: [background colour];
  color: [text colour];
  font-size: [font size]px;
  padding: [padding Y]px [padding X]px;
  border-radius: [radius]px;
  border: [border width]px solid [background colour];
  box-shadow: [shadow];
}
.btn:hover {
  background: [hover colour];
}
Shadow values: none = box-shadow: none; soft = 0 4px 12px rgba(0,0,0,0.15); strong = 0 8px 24px rgba(0,0,0,0.25).

Worked example: With the defaults — “Get started”, background #673DE6, white text, 16px type, 12px by 24px padding, 8px radius and a soft shadow — the CSS is a .btn rule with background #673DE6 and a :hover rule that switches the background to #5A2EDB. Pick the Pill preset and the radius jumps to 32px, giving the same button fully rounded ends.

Frequently asked questions

How do I use the code on my site?

Copy the CSS into your stylesheet and the HTML where the button should appear. The class name is .btn, so if your site already uses that name, rename it in both places first.

What does padding X and Y mean?

Padding X is the space left and right of the text, padding Y is the space above and below it. More horizontal padding makes a wider button; more vertical padding makes a taller one.

Why does the hover colour matter?

A hover colour tells visitors the button can be clicked. Pick a slightly darker shade of the background colour — the default #5A2EDB is a darker version of #673DE6.

When should I add a border?

Most solid buttons need no border. Add a 1–2px border when the button sits on a coloured background and needs an edge to stand out, or when you want an outline style.

What is the difference between soft and strong shadow?

Soft is a small, light shadow for a gentle lift off the page. Strong is bigger and darker, for a button that should draw the eye — best used sparingly, once per page.

More tools

Tell us what you think

Loving this tool, or stuck on something? Tell us — it takes a minute.

We’ll only use your name and email to reply if needed. The tool and page are filled in for you.