Action
A button should represent an action, not ordinary navigation text.
Buttons are action components. Good button CSS makes actions obvious, touch-safe, keyboard-safe and visually consistent.
.button {
min-height: 44px;
display: inline-flex;
align-items: center;
justify-content: center;
}
.button:focus-visible { outline: 3px solid var(--focus); }
Component mental model
A button is not just a rounded rectangle with text. It is a promise that something will happen when the user activates it.
Good button styling communicates priority, state and affordance. Primary actions should stand out, secondary actions should support, and destructive actions should be unmistakable.
Production buttons need hover, focus-visible, active, disabled, loading and touch-safe sizing. A button without states is only half a component.
A button should represent an action, not ordinary navigation text.
Primary, secondary and danger variants guide decisions.
Hover, focus, active, disabled and loading need deliberate styling.
The clickable area must be comfortable for mouse, keyboard and touch.
Visual model
Good CSS versus fragile CSS
.button {
min-height: 44px;
display: inline-flex;
align-items: center;
justify-content: center;
gap: .5rem;
border-radius: 999px;
}
.button:focus-visible { outline: 3px solid var(--focus); }
.button:active { transform: translateY(1px); }
.btn {
padding: 6px 8px;
border-radius: 4px;
color: white;
}
Rules of thumb
Use button elements for actions and links for navigation.
Primary, secondary, subtle and danger variants should be consistent.
Never remove outlines without replacing them with a clear focus-visible style.
Small active feedback makes buttons feel responsive.
Disabled buttons should look unavailable and avoid fake hover effects.
A 44px minimum height is a strong baseline for real interfaces.
Production thinking
Buttons are where users commit. Weak button styling creates hesitation, misclicks and uncertainty.
Buttons need focus-visible, sufficient contrast and accessible names, especially for icon-only actions.
Centralize button CSS early. Random one-off buttons multiply quickly and make a product feel inconsistent.
Buttons do not directly improve SEO, but clear actions improve engagement and reduce friction.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If a state, long label or mobile width breaks the component, the component is not finished yet.
Senior audit upgrade
A polished button system includes text buttons, icon buttons, loading states, disabled states and focus states.
Give icon-only buttons an accessible name with visible text nearby or aria-label.
Prevent double submission and show that the action is in progress.
Keyboard focus must be at least as clear as hover.