Using the WCAG Color Contrast Checker
The WCAG Color Contrast Checker compares two hex colors. Foreground starts at #000000. Background starts at #ffffff. Choose Check contrast. The label above the headline reads Contrast ratio. The headline is 21. The ratio line is 21. The normal-text line is Passes 4.5. The sentence says the contrast ratio is 21, and that normal text passes the 4.5 ratio. The page does not test a screenshot.
The ratio is (lighter luminance + 0.05) divided by (darker luminance + 0.05). The page converts each hex color to relative luminance, puts the larger luminance on top of that formula, and compares the ratio with 4.5. For black #000000 and white #ffffff the ratio is 21. Normal text passes because 21 is at least 4.5. The steps under the result say to convert each hex color to relative luminance, divide the lighter luminance plus 0.05 by the darker plus 0.05, and compare the ratio with 4.5. Check the same pair again and the headline stays 21.
Swap the fields so foreground is #ffffff and background is #000000. The lighter luminance is still white and the darker is still black, so the headline is still 21 and the normal-text line still reads Passes 4.5. The same two colors in either field order rebuild 21. A three-digit hex is expanded before the math. #000 and #fff are the same black and white, and the headline is 21 again. A word such as red is rejected. The headline reads Foreground must be a hex color.
The same color in both fields is a ratio of 1. #000000 and #000000 produce the headline 1. The sentence says the contrast ratio is 1, and that normal text does not pass the 4.5 ratio. The normal-text line reads Below 4.5. The page does not test a screenshot for that pair either. It only compares the two hex values you typed.
Copy result copies the sentence. For the starting fields it says the contrast ratio is 21, and that normal text passes the 4.5 ratio. Reset returns the fields to #000000 and #ffffff, and the headline to Enter two colors. Copy the sentence before you reset. The page accepts #RGB and #RRGGBB. It does not accept a color word. Background text that is not hex says Background must be a hex color. Hex digits may be upper or lower. #FFFFFF is the same white as #ffffff, and with #000000 the headline is still 21. The page lowercases the field before it reads the digits. The normal-text line still reads Passes 4.5 for that pair. A ratio is shown with trailing zeros trimmed, so 21 does not appear as 21.00. The same trimming leaves the identical-color ratio as 1, not 1.00. Use the normal-text line to see the 4.5 comparison. Passes 4.5 and Below 4.5 are the only two marks that line uses.
What the Ratio Measures
The ratio compares the relative luminance of the two hex colors you typed. For #000000 and #ffffff, the headline is 21. The label above it reads Contrast ratio. The ratio line is 21. The normal-text line is Passes 4.5. The sentence says the contrast ratio is 21, and that normal text passes the 4.5 ratio. The page does not test a screenshot. The pass mark on this page is 4.5. A ratio of at least 4.5 is Passes 4.5. A smaller ratio is Below 4.5.
The formula uses the lighter luminance plus 0.05, divided by the darker luminance plus 0.05. Field order does not pick the lighter color. The page chooses the larger luminance for the top of the formula. That is why #ffffff on #000000 is still 21. Two copies of #000000 are a ratio of 1, and normal text does not pass. Read the normal-text line with the headline. The headline is the ratio. The line says whether that ratio meets 4.5. The page does not apply a second threshold on this screen. 21 passes because it is greater than 4.5. 1 does not pass because it is smaller than 4.5. Those two sample pairs are enough to see both marks. The colors still have to be hex. A word never reaches the formula.
How Black and White Become 21
The page reads each field as hex. #000000 is black. #ffffff is white. It turns each color into relative luminance. White is the lighter luminance. Black is the darker. The ratio is (lighter luminance + 0.05) divided by (darker luminance + 0.05), which is 21 for this pair. The headline is 21. Normal text passes the 4.5 ratio, so the normal-text line reads Passes 4.5. The page does not test a screenshot. A three-digit form of the same colors, #000 and #fff, expands to the same hex and the headline is 21 again.
A simulated recolor of one hex value is a different result. The Color Blindness Simulator recolors one hex value with a published simulation matrix. The result is an approximation of the typed color, not a diagnosis and not a test of a person’s vision. The types are protanopia, deuteranopia, and tritanopia. Use it when you want that approximation of one color. Use this page when you want the contrast ratio of two hex colors. 21 is the black and white ratio. It is not a simulated recolor.
What the Page Accepts as a Color
Each field must be hex. A leading # is optional in the sense that the page strips one, and the remaining characters must be 3 or 6 hex digits. #000000 and #ffffff are the sample. #000 and #fff expand by repeating each digit, and they produce the same ratio, 21. A word such as red is rejected with Foreground must be a hex color. A word in the background field is rejected with Background must be a hex color. The lines are cleared when a field fails. The page does not test a screenshot to guess what the word meant.
There is no third color and no image field. The ratio is only the two luminances. The page does not sample a screenshot, a photo, or a page on a screen. If the colors you care about are in a picture, you type their hex values yourself. The headline then follows the formula. For black and white that headline is 21, and normal text passes the 4.5 ratio.
Black on White, Then the Same Black Twice
Leave foreground at #000000 and background at #ffffff. Choose Check contrast. The headline is 21. The ratio line is 21. The normal-text line is Passes 4.5. The sentence says the contrast ratio is 21, and that normal text passes the 4.5 ratio. Check again. The figures match. Swap the two fields. The headline stays 21, because the lighter luminance is still white. Set both fields to #000000. The headline is 1. The normal-text line is Below 4.5. The sentence says normal text does not pass the 4.5 ratio. Restore #000000 and #ffffff. The headline returns to 21.
A shadow declaration uses a hex color and does not compute this ratio. The CSS Box Shadow Generator builds one box-shadow declaration from offsets, a blur, a spread, and a color. 4, 8, 16, 0, and #000000 becomes box-shadow: 4px 8px 16px 0px #000000;. That page does not apply it to a stylesheet. Use it when you want that declaration. Use this page when you want the contrast ratio of two hex colors. The shadow string is not the ratio 21.
Hex Only, and the 4.5 Line
Foreground and background must be hex colors. Three hex digits or six hex digits are accepted, with or without a leading #. Anything else fails. A word such as red says Foreground must be a hex color. A non-hex background says Background must be a hex color. The ratio line and the normal-text line are cleared when that happens. The page does not test a screenshot and does not substitute a hex value for the word.
On a successful run the normal-text line is Passes 4.5 when the ratio is at least 4.5, and Below 4.5 when it is smaller. Black and white are 21, so the line reads Passes 4.5. The same color twice is 1, so the line reads Below 4.5. The headline shows the ratio with trailing zeros trimmed, which is why 21 stays 21 and 1 stays 1. The page does not round 21 to another whole number.
Pairs People Expect the Page to See
A common miss is to type the word red and expect a ratio. The headline reads Foreground must be a hex color. The page wants hex, such as #000000. Another miss is to think field order changes black and white. #000000 and #ffffff are 21 in either order, because the formula uses the lighter luminance over the darker. Another miss is to read Passes 4.5 as a test of a screenshot. The page does not test a screenshot. Another miss is to treat a ratio of 1 as a pass. #000000 on #000000 is 1, and normal text does not pass the 4.5 ratio. Another miss is to forget that #000 and #fff expand to the six-digit pair and still return 21.
A grid declaration does not compare two colors. The CSS Grid Generator builds a grid container with equal columns. 3 columns and a gap of 16 becomes repeat(3, 1fr) and gap 16px. The declaration sets display to grid. That page does not write a stylesheet. Use it when you want that grid CSS. Use this page when you want the contrast ratio. repeat(3, 1fr) is not the ratio 21, and the grid page does not test a screenshot either.
21, Then 1, Then a Rejected Word
Enter foreground #000000 and background #ffffff. Check contrast. The headline is 21 and the normal-text line is Passes 4.5. Enter #fff and #000. The headline is 21 again, because the three-digit colors expand to white and black. Enter #000000 in both fields. The headline is 1 and the normal-text line is Below 4.5. Restore #000000 and #ffffff and confirm 21 returns. The page does not test a screenshot on any of these runs.
Enter the word red in the foreground and check again. The headline reads Foreground must be a hex color. Restore #000000. Enter the word red in the background. The headline reads Background must be a hex color. Restore #ffffff. Confirm the sentence again says the contrast ratio is 21, and that normal text passes the 4.5 ratio. The ratio line should read 21.
Keeping Both Colors With the Ratio
Copy the sentence. For the sample it says the contrast ratio is 21, and that normal text passes the 4.5 ratio. Write #000000 and #ffffff beside it. The page does not store the run, and it does not test a screenshot. A note that says only 21 can be this black and white pair. The same color twice is 1, and that sentence says normal text does not pass. Keep the sentence that matches the two hex values you used. Field order does not change 21 for this pair, but the written colors should still be the ones you typed.
A flex container is a different record. The CSS Flexbox Generator builds a flex container declaration. Row, flex-start, stretch, and a gap of 16 becomes display flex, flex-direction row, justify-content flex-start, align-items stretch, and gap 16px. That page does not write a stylesheet. Use it when you want that CSS. Use this page when you want the contrast ratio of two hex colors. The flex declaration is not the ratio 21, and it does not say whether normal text passes 4.5.
A Ratio From the Two Hex Colors You Typed
The headline answers the contrast ratio of the two hex colors. #000000 and #ffffff is 21. Normal text passes the 4.5 ratio. The ratio is (lighter luminance + 0.05) divided by (darker luminance + 0.05). The same pair in the other order is still 21. #000000 and #000000 is 1, and normal text does not pass. A word such as red is rejected with Foreground must be a hex color. The page does not test a screenshot. Those outcomes come from the fields.
Checking 21 Against the 4.5 Line
Enter #000000 and #ffffff. The headline should be 21. The normal-text line should read Passes 4.5, because 21 is at least 4.5. Swap the fields and confirm 21 again. Enter the same hex in both fields. The headline should be 1, and the normal-text line should read Below 4.5. Enter the word red. The headline should read Foreground must be a hex color. The page does not test a screenshot on the successful run. The label above a successful headline reads Contrast ratio. The formula remains (lighter luminance + 0.05) divided by (darker luminance + 0.05).
An alt sentence does not replace that ratio. The Alt Text Generator writes one alt sentence from the subject you type. A subject of a red bicycle becomes Photo of a red bicycle. That page does not look at an image. Use it when you want that sentence. Use this page when you want the contrast ratio of two hex colors. Photo of a red bicycle is not the ratio 21. The word red in a contrast field is rejected. The hex colors are what this page compares.