Skip to content
To the Tech

CSS buttons: check label, focus and contrast together

When designing or auditing web buttons, accessibility depends on three distinct visual layers: the legibility of the text label, the visibility of the focus indicator for keyboard users, and the contrast between these elements and their backgrounds. Testing only the default state often misses failures that occur during hover or keyboard navigation.

New editorial edition, December 2026. This historical address is retained for existing links; the text below is newly written.

Text Contrast Requirements

To meet WCAG 2.2 Success Criterion 1.4.3 (Level AA), standard text must maintain a contrast ratio of at least 4.5:1 against its background. While large-scale text (at least 18pt regular or 14pt bold) may use a lower 3:1 threshold, most button labels fall into the standard text category and require the higher 4.5:1 ratio.

Note that inactive (disabled) controls and purely decorative text are exempt from these specific contrast requirements. However, once a button is interactive, the label must be clearly readable.

Focus Visibility

Keyboard-operable interfaces must provide a visible indicator when an element receives focus (SC 2.4.7). This indicator should persist as long as the focus remains on the element. While there is no single universal rule for the size or style of a focus outline, the indicator must be clearly distinguishable from the surrounding interface.

Focus information may also be subject to non-text contrast requirements to ensure the indicator itself is visible against the button or page background.

The Three-State Audit Method

Check these three common visual states as part of the button review. This is a label-and-focus check, not a complete accessibility assessment of semantics, activation and every application state.

Normal: The default appearance of the button.

Hover: The appearance when a mouse pointer is over the button.

Focus: The appearance when the button is selected via keyboard navigation (usually via the Tab key).

Button State Test Worksheet

These are calculated examples for opaque sRGB colour pairs, using the WCAG relative-luminance formula. They are not measurements of a rendered page. The ratio checks the text label; inspect the focus indicator separately.

Interaction StateForeground (Text) ColorBackground ColorCalculated text contrastLabel Legibility (4.5:1)
Normal#FFFFFF (White)#0055FF (Blue)5.61:1Pass
Hover#FFFFFF (White)#0033AA (Dark Blue)10.22:1Pass
Focus#000000 (Black)#FFFF00 (Yellow)19.56:1Pass
  • Does the text label meet a 4.5:1 contrast ratio in the Normal state?
  • Does the text label maintain at least 4.5:1 contrast during the Hover state?
  • Is there a visible indicator (such as an outline) when the button is in the Focus state?
  • Is the focus indicator clearly visible against both the button color and the page background?

Check the label contrast in each relevant state and inspect keyboard focus separately; a passing colour pair does not establish complete accessibility.

Open the practical tool →