CSSFeb 28, 2026 · Updated Oct 13, 2026·4 min

CSS Button Styles: Every Technique Explained

🔘
Try the Button Generator
Build custom CSS buttons with live preview
→
DG
Derek Giordano
Designer & Developer
In this guide
01Anatomy of a CSS Button02Browser Reset & Base Styles03Solid Buttons04Outline Buttons05Gradient Buttons06Hover & Active States07Focus Indicators & Accessibility08Loading & Disabled States09Size Variants & Touch Targets10Best Practices

Anatomy of a CSS Button

A well-designed button has four layers: layout, visual, typography, and interaction states. Missing any layer produces a button that looks or behaves poorly.

Semantic HTML matters. Use button for actions and a for navigation. Every button needs default, hover, and focus-visible states at minimum.

Browser Reset & Base Styles

Browsers apply default button styles that vary across platforms. A proper reset removes these inconsistencies.

Set cursor: pointer, font-family: inherit, and add transition: all 0.2s ease so state changes animate smoothly.

button { border: none; background: none; cursor: pointer; font-family: inherit; transition: all 0.2s ease; }

Solid Buttons

Solid buttons have a filled background and contrasting text. They are the primary action style. Keep colors limited: primary, secondary, and destructive.

Padding controls the clickable area. Common pattern: 12px vertical, 24px horizontal. Border-radius between 6-12px is standard for modern interfaces.

Outline Buttons

Outline buttons use transparent background with colored border and text. They serve as secondary actions — Cancel next to Submit.

Set border width to 1.5-2px. On hover, fill the background with the border color and change text to white.

Gradient Buttons

Gradient buttons draw more attention than solid ones, so keep them for the single most important action on a page. Check the text against every stop of the gradient, not the average. The popular coral-to-orange pair #FF6B6B → #FF8E53 with white text measures 2.78:1 at the first stop and 2.27:1 at the second (WCAG formula), well under the 4.5:1 that WCAG 1.4.3 asks for normal-size text and under the 3:1 allowed for large text. The same gradient with dark #0B0D17 text measures 6.98:1 and 8.53:1. If the brand needs white text, darken both stops until each passes.

.btn-gradient { background: linear-gradient(135deg, #FF6B6B, #FF8E53); background-size: 200% auto; color: #0B0D17; /* 6.98:1 and 8.53:1 on the two stops */ transition: background-position .3s ease; } .btn-gradient:hover { background-position: right center; }

Hover & Active States

Hover: darken with filter: brightness(0.9), add a shadow, or lift with translateY(-1px). Re-check contrast for the hover colors too; a hover state that drops below 4.5:1 is still text a user has to read. Active: translateY(1px) and a smaller shadow, with no transition delay, so the press feels immediate. Prefer animating transform, background-color and box-shadow by name instead of transition: all, which also animates layout properties you did not mean to change.

Focus Indicators & Accessibility

Focus indicators tell keyboard users which element is selected. Never remove the outline without replacing it. :focus-visible shows the ring for keyboard focus and usually not for mouse clicks. A solid outline of at least 2px with an offset meets the size part of WCAG 2.4.13 Focus Appearance (AAA in WCAG 2.2); the criterion also asks for 3:1 contrast between the ring's pixels when focused and the same pixels unfocused, which a #FF6B6B ring over a #0B0D17 page gives (6.98:1).

button:focus-visible { outline: 2px solid #FF6B6B; outline-offset: 2px; }

Loading & Disabled States

A common loading pattern sets pointer-events: none so the button cannot be clicked twice. It does not do that for keyboard users. In our Chromium test (below), a button with pointer-events: none ignored a mouse click but fired its click handler twice when focused and given Enter and Space. Block the action in your handler (or set disabled / aria-disabled="true" and check it), and announce the busy state with aria-busy="true" or a live region rather than relying on the spinner alone.

The native disabled attribute stops both mouse and keyboard and also removes the button from the tab order (confirmed in the same test), so users cannot discover why it is disabled. When the reason matters, use aria-disabled="true", keep the button focusable and explain next to it. WCAG's contrast requirements do not apply to inactive components, but a disabled state at 0.4–0.5 opacity should still be recognizable as a button.

Size Variants & Touch Targets

We rendered the common size scale in Chromium with a system font:

SizePadding, fontRendered heightWCAG 2.5.8 (24 px, AA)WCAG 2.5.5 / Apple HIG (44)
Small6px 14px, 13px27 pxPassesFails
Medium10px 20px, 14px36 pxPassesFails
Large14px 28px, 16px47 pxPassesPasses
"Standard" 12px 24px12px 24px, 16px43 pxPasses1 px short

So "44 px everywhere" and "12px 24px padding" are not the same rule: the padding gives 43 px at 16px text. WCAG 2.2's level AA criterion 2.5.8 (Target Size, Minimum) needs 24×24 CSS px or enough spacing around smaller targets; 44×44 is the stricter AAA criterion 2.5.5 and Apple's Human Interface Guidelines figure (44 pt). Setting min-height: 44px on touch-first buttons is simpler than tuning padding per font.

Best Practices

Limit button styles per page. One primary, one secondary, one tertiary, one destructive covers every use case.

Test at every viewport width. A button that works at 1440px might overflow at 320px. Mobile testing is not optional.

Build custom CSS buttons

Design buttons with hover effects, shadows, and gradients.

⚡ Open Button Generator
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.