CSS named colors and how nearest-name matching works
Where the CSS color keywords come from, when to use a name over a hex code, and how RGB distance picks the closest one.
Where the CSS color names came from
The list of CSS keyword colors grew out of the early web and the X Window System palette, which is why it contains both plain entries like red and blue and oddly specific ones like papayawhip, gainsboro, and lightgoldenrodyellow. Over time the set was standardised so that every modern browser resolves the same keyword to the same value. The most recent notable addition is rebeccapurple, added in memory of a developer's daughter, which is why a seemingly arbitrary shade of purple sits in an otherwise historical list.
When a name beats a hex code
A keyword like tomato or steelblue is easier to read and remember than an equivalent hex string, which makes stylesheets friendlier to scan and to hand off. Names are handy for quick prototypes, teaching examples, and any place where the exact shade matters less than clear intent. The trade-off is precision: there are only about 140 keywords, so once a design needs a specific brand shade you will reach for hex or rgb instead. Knowing the nearest keyword to a custom color is a nice middle ground, giving you a memorable label to talk about a value even if you ship the exact code.
How nearest-name matching works
To find the closest keyword the tool treats each color as a point in a cube whose three axes are red, green, and blue from 0 to 255. It measures the straight-line distance from your color to every named color and keeps the smallest. A distance of 0 means a perfect hit, small numbers mean the nearest name is visually almost the same, and larger numbers warn you that the closest keyword is only a loose stand-in. This is the same idea as measuring the gap between two points on a map, just carried into three dimensions.
The limits of RGB distance
Plain RGB distance is fast and easy to reason about, but it does not match human perception evenly. Our eyes are far more sensitive to differences in green than in blue, so two pairs of colors with the same numeric distance can look noticeably different in how far apart they seem. Perceptual color spaces such as CIELAB were designed to correct this, at the cost of more complex math. For naming a color the simple approach is usually good enough, and treating the distance as a rough closeness score rather than an exact perceptual measure keeps expectations sensible.