Match an Opaque HEX Swatch to a CSS Named Color
Admin ·
A CSS keyword can describe a color in a handoff or replace an exact HEX value in a stylesheet. Compare the numbers first so you can tell an exact equivalent from a nearby named swatch.
Find the nearest CSS color to the coral sample
Choose Coral to enter #FF6B6B. The top result is salmon at #FA8072. Compare the two swatches before deciding whether it is suitable as a named replacement.
The input has RGB channels 255, 107 and 107. Salmon has 250, 128 and 114. Square each channel difference, sum the squares and take the square root. The result is √515, displayed as 22.69 RGB distance.
| Result | HEX | RGB distance |
|---|---|---|
| salmon | #FA8072 | 22.69 |
| lightcoral | #F08080 | 33.27 |
| coral | #FF7F50 | 33.60 |
Open the HEX to Named Color exampleW3C CSS opaque named colorsW3C CSS hexadecimal notation
Read the similarity percentage
The largest Euclidean RGB distance is from black to white. It equals 255 × √3. Dividing the candidate distance by that maximum and subtracting from one gives the similarity proportion. Salmon displays as 94.86% similar for the coral sample.
The calculation works in encoded sRGB. For a visually sensitive substitution, compare the rendered colors in the actual design. To keep the original numerical value in CSS, use your original HEX unless the named match is exact.
Open the HEX to Named Color exampleW3C CSS opaque named colors
Verify an exact shorthand match and aliases
Enter #0ff. CSS HEX shorthand repeats each digit, so the input expands to #00FFFF. Aqua and cyan share that value and appear in the same card with 100.00% similarity.
Copy either keyword and paste it into a CSS declaration. For the coral example, copying a keyword intentionally substitutes a different swatch. The RGB and HSL buttons on each card provide formats for that card’s named swatch.
Common questions
Will two exact aliases take two places in the six results?
Equivalent names appear on one swatch card, leaving room to compare six distinct sRGB colors.
Does the similarity percentage measure text contrast?
It measures distance between encoded RGB channels. To assess text contrast, compare the actual foreground and background in a contrast checker.