HIYSL REFERENCE / FIELD NOTES

How to Choose Between Black and White Text for a Background Color

Contents
AI-generated illustration; not taken on location · Diagram comparing black and white text on matching colored backgrounds.
AI-generated illustration; not taken on location · Compare both text colors against the same background.AI-generated illustration

To choose between black and white text, test both colors against the background immediately behind the words. Compare each contrast ratio with the target that applies to your text and its intended use. If both meet that target, use the results alongside the needs of the content to make your choice.

The color that looks clearer at first glance is a useful starting point, but a contrast check gives you a result to compare with the relevant requirement. The process also helps when a background changes across an image, when text appears on several colored surfaces, or when the same content will be used in another format. Start with the actual combination a reader will encounter, then check the finished version wherever that combination changes.

Identify the background color

First, locate the color directly behind the text you want to assess. If a page has a colored panel inside a differently colored page, use the panel color for text on that panel. If a label sits on a button, identify the color behind the label rather than the surrounding area. The contrast decision concerns the particular text and background combination, so make a separate note for each one you need to check.

Find the background value in a format your chosen contrast checker accepts. Manual checkers can work with selected colors, hex codes, or RGB values, depending on the checker. If you already have the value, keep it handy. If you are choosing or identifying a color visually, use an available color-selection method and check which value it provides before entering it. You do not need to convert a value by hand if your checker accepts the format you have.

When the background is not a single color

A photograph, illustration, gradient, or patterned surface can have different colors behind different parts of a sentence. Ask which colors actually appear behind the words, including where the background changes. Identify the combinations that need checking rather than relying on a color from an unrelated part of the image.

For example, if a heading crosses a light area and a dark area, compare the text against both areas. A choice that works over one part may need a different treatment over another. You could consider placing the text on a consistent background, moving it, or changing the background treatment, then testing the resulting combination.

If you cannot determine the color behind the text, pause before choosing a text color. Obtain the relevant value or use a checker that lets you select the colors you need. Record enough detail to associate the value with the particular heading, label, or paragraph you are checking.

Compare black and white

With the background identified, use a contrast checker to make two comparisons. Keep the background value the same for both: first pair it with black text, then pair it with white text. Note each resulting ratio and which text color produced it. Keeping the background fixed makes the two results useful for the decision you are trying to make.

Comparison Background Text color Record
First Your chosen background Black The displayed contrast ratio
Second The same background White The displayed contrast ratio

Read the two results together. The higher ratio tells you which of the two colors has greater contrast against that background. It does not, by itself, tell you whether the lower ratio is sufficient or whether the higher one meets the target for your use. You still need to compare each result with the applicable target.

Contrast ratios use relative luminance. Black and white achieve the maximum contrast ratio when compared with each other, but your test pairs each text color with your chosen background. The useful result is therefore the ratio for each actual pairing, not an assumption based only on whether the background looks colorful, muted, light, or dark.

Keep the comparison consistent

If your checker asks you to enter separate foreground and background colors, place the text color in the foreground and the surface color in the background. Use the same background input in both tests. Before recording the results, check that you have not accidentally left a previous text or background value in place.

For a practical example, suppose you are choosing text for a colored announcement panel. Enter the panel’s value and compare it with black; write down the result beside “black on announcement panel.” Then use the same panel value with white and record that result beside it. You now have two results to evaluate against the requirement, without needing to guess a ratio from the panel’s appearance.

Choose a color against the applicable target

Find the contrast target that applies to the text, the relevant accessibility standard, and the way the content will be used. Text size can affect which target applies, so identify the size and context before deciding whether either result is sufficient. If you are unsure which standard or target to use, check the requirements for your project or consult the relevant guidance for the format.

Compare the black-text result and the white-text result separately with that target. This produces a decision you can act on:

  • If only one result meets the target, choose that text color for the tested background.
  • If both meet it, consider which offers greater contrast and which suits the content and its presentation.
  • If neither meets it, adjust the background or consider another text color, then test the new combination against the same applicable target.
  • If you do not yet know the target, keep both results and resolve the requirement before treating either choice as sufficient.

The higher ratio is useful in every comparison, but it is not a substitute for the target. For instance, a higher result could still fall short of a requirement; equally, both results might meet it. The action depends on the recorded ratios and the applicable target, not on the ranking alone.

If both options meet the target

Look at the higher-contrast option first, then consider the content as readers will see it. A short, prominent heading and a longer passage may call for different presentation choices, even when the same two colors have been tested. Check that your choice also works consistently with the other text and backgrounds in the piece.

Keep the decision tied to the actual text. If you change its size, move it to another surface, or prepare it for a different use, check whether the same target and color pairing still apply. Where a project has its own requirements in addition to an accessibility standard, check those before settling on the final treatment. For guidance on testing color contrast in documents and images, consult Section508.gov.

Check the finished context

After making your initial choice, review the text in the finished content. Check each distinct text and background combination: a title on a panel, a label on a button, and a caption over an image may each need their own comparison. A result for one pairing does not establish the result for a different background.

Work through the content in a consistent order. For each item, identify the words, the surface directly behind them, the chosen text color, and the target that applies. Then confirm that the recorded ratio corresponds to that combination. If the background changes under a line of text, check the relevant areas and revise the presentation if the choice does not meet the target across them.

Review other versions

If the content will appear in another format, inspect that version too. A document, an image, and another presentation of the same message may place text on different backgrounds. Identify the colors in each finished version and repeat the comparison where the combination changes. Also check whether the same accessibility target applies to that use before relying on an earlier result.

A small record can make revisions easier: note the text or location, the background value, the black and white results, the target used, and the color selected. If someone later changes the panel color or moves the words onto an image, they can see which decision needs to be revisited. Record the result for the final combination after any adjustment, rather than keeping only the first test.

Before publishing or sharing, ask four questions: Is this the background actually behind the words? Was the chosen text color tested against it? Does the result meet the applicable target? Has the combination changed anywhere else the content appears? If an answer is uncertain, return to that specific pairing and check it. The aim is a decision that holds for the content readers receive, not just for an isolated color sample.

Sources