1 minute read

Web colors can be specified in Cascading Style Sheets (CSS) in a variety of ways. Including using CSS color names or 3- or 6-digit hexadecimal (base 16) values (or 4- or 8-digit hex values when including the optional alpha / opacity argument of RGBA). Later versions of the CSS standard include CSS Color 4 and CSS Color 5 with several enhancements.

Because Iā€™m slightly color blind, I typically use colors from the 216 web-safe colors on my websites. (ColorHexa has an interesting Color Blindness Simulator as part of their color pages to help with web accessibility.) See this reference for a complete description of CSS colors.

Named colors

CSS Colors can be specified as one of the case-insensitive CSS color names. There are 148 named colors that come from 16 original VGA colors, 131 of the 504 X11 colors, and rebeccapurple. (https://youtu.be/HmStJQzclHc is a history of the names ā€” who knew there was a Crayola 72 pack?)

Hexadecimal colors

CSS Colors can be specified as a hexadecimal number preceded by a hash character (#). The standard way to specify a color in an RGB color space is to use three two-digit hexadecimal numbers, one for each color. That yields 256 levels (from 00 to ff) of red, green, and blue. The color numbers can be specified as either 3 or 6 hexadecimal digits, where the 3-digit number simply repeats each digit twice. For example, rebeccapurple can be specified as either #639 or #663399.

Updated: