FIELDNOTES / GUIDE

How to Check Color Contrast in Light and Dark Modes

On this page
AI-generated illustration; not taken on location · Illustrated light and dark color pairs with text on adjacent backgrounds.
AI-generated illustration; not taken on location · A conceptual comparison of foreground and background colors in two themes.AI-generated illustration

To check contrast in light and dark modes, compare each visible text or interface color with the background immediately beside it in the same theme and state. Enter those two colors into a contrast checker, note the result, and compare it with the accessibility criterion that applies to the element you are checking.

Work through the interface one combination at a time. A button label, its surrounding fill, its border, and its focus indicator may each need a separate comparison. Repeat the process in both themes and after meaningful changes, keeping a short record so you can find and fix combinations that fall short.

Collect color pairs in each theme

Start with a screen you use often and set it to light mode. List the text, icons, controls, and other meaningful visual elements you can see. For each one, identify the color of the element and the background it actually touches. Then switch to dark mode and repeat the exercise; treat the dark-theme pair as a separate entry.

A useful starting list might include page headings, body text, links, button labels, form labels, input borders, and icons that convey information. A label inside a colored button should be compared with the button fill, while text beside the button should be compared with the surface behind that text. If a border touches different surfaces on its inside and outside, record those relationships separately for review.

Obtain the displayed colors using information available to you, such as the color values provided with the interface or a way to sample the visible screen. If you use a sampling method, check that it captures the area you intend to compare. Record values in a format accepted by your chosen checker, along with the element’s location and theme.

If you cannot determine a color reliably, mark it for follow-up rather than guessing. Ask whoever can provide the design details for the actual colors used in that theme and state.

Check interactive states

The colors visible before you interact with a control may not be the colors you need to check later. Visit each relevant state in turn: for example, move the pointer over a control to inspect hover, use the keyboard to reach a focus state, and look at selected or error states where they are available. Repeat those observations in light and dark modes.

For each state, record what changes and what it touches. A hovered button might have a different fill, so its label needs to be compared with that fill. A focus indicator may need its own comparison with the adjacent color or colors. An error message and an input border may also be separate elements with different neighboring backgrounds.

Use a small state checklist to avoid losing your place: default, hover, focus, selected, and error are useful prompts, but include only states relevant to the interface. If a state appears only after a particular action, note that action in your record so you can reproduce it during retesting.

When a state is difficult to trigger or inspect, ask for a way to view it or for its color values. Keep the entry open until you can check the colors that actually appear.

Measure and interpret each combination

For each entry, open a contrast checker and provide the two colors being compared: the foreground, such as text or an icon, and its adjacent background. Use the input format the checker requests. Read the resulting contrast ratio and write it beside the pair, with enough context to identify the theme, element, and state.

For example, a record might say “dark theme, primary button, hover: label color against button fill.” The same label in the default state belongs in another entry if either color changes. This makes the result actionable: you can see exactly which combination needs attention instead of giving an entire screen one score.

Next, compare the result with the accessibility criterion relevant to what you are checking. Text and interface elements can be subject to different requirements, so identify the element and consult the applicable guidance before deciding whether the result meets it. If a checker offers a category or result label, verify that it corresponds to the element and criterion you intend to assess.

If you are unsure which criterion applies, record the ratio and the question for follow-up. The Section508.gov guidance on accessible color use is a place to start. A result is most useful when the comparison and the basis for interpreting it are both clear.

Handle changing backgrounds

Text over an image or gradient needs more than a single convenient background sample. Look at several areas behind the text, compare each sampled background color with the text color, and identify the weakest result for further adjustment. Record where you sampled so the comparison can be repeated.

For a heading spanning a gradient, for example, check areas behind the beginning, middle, and end of the heading, as well as any other area that appears likely to produce a weaker combination. For text on an image, inspect the areas directly behind the letters rather than an unrelated part of the picture. If the image, text position, or visible crop can change, note the variations you can inspect and repeat the comparison for them.

Several samples can help identify a problem, but a small set of samples does not establish the result for every possible image or layout. If the background can vary beyond what you can inspect, ask how that variation will be handled and what should be checked when it changes.

Where the weakest result needs improvement, consider changing the text color or providing a more consistent background behind the text. Recheck the adjusted combination in context and in each affected theme.

Adjust, retest, and record results

When a combination falls short of the criterion you are using, identify which color can reasonably change. You might adjust the text or icon color, the adjacent surface, or both. For a focus indicator or border, consider its relationship to each adjacent color you recorded. Make one change at a time where practical, then measure again so you can tell which adjustment addressed the problem.

Check the result in the interface as well as in the checker. A color may be reused in more than one place or state, so list the combinations affected by the change and retest each one. If a button fill changes, for example, revisit its label and any border or indicator that touches it. Repeat the relevant checks in the other theme if that theme also uses the changed color.

A simple table can keep the work manageable:

Theme and location Element and state Colors compared Result and next step
Light, sign-in screen Button label, default Label and button fill Record ratio; compare with applicable criterion
Dark, sign-in screen Button label, hover Label and hover fill Record ratio; adjust and retest if needed

Replace the example descriptions with actual color values and results. Add the criterion used, the date or version you checked, and an owner for any unresolved question if those details help you return to the work.

Make meaning clear without color alone

A contrast result addresses a color comparison, but readers also need to understand what an element means. Look for places where a change in color is the only cue that something is a link, an error, a selection, or another meaningful state. Add or retain a second cue that makes sense in that context.

For links, an underline or a clear label can help distinguish the action. For an error, pair the color treatment with a message that explains what needs attention. For a selected option, consider a visible label or another indicator alongside the color. Icons can also help when their meaning is clear in context; check the icon and any accompanying text against their adjacent backgrounds in each theme.

Try reading the screen by its labels and other cues: can you tell what needs correction, what is selected, and which text is an action? If not, make the cue more explicit and inspect the revised state again. Record any new text, icon, or indicator as another combination to check.

Finish by reviewing unresolved entries. Each should say what needs to be obtained, adjusted, or checked, so the next review can pick up where you left off.

Sources

← Return to the tools