Web colors

Web colors are the digital paints that bring the internet to life, dictating how everything from text to images appears on our screens. They're a fundamental part of web design, bridging the gap between human perception of color and the precise language computers understand. Understanding how these colors are defined and rendered reveals a fascinating interplay of art and engineering. Web colors are primarily defined using the RGB color model, allowing for millions of distinct hues to be displayed. Hexadecimal codes provide a compact and precise way to specify these RGB values, essential for consistent web design. The evolution of web standards has moved from a limited 'web-safe' palette to supporting a vast spectrum of colors and advanced color spaces.

Source: Wikipedia

AI Summary

Web colors are the digital paints that bring the internet to life, dictating how everything from text to images appears on our screens. They're a fundamental part of web design, bridging the gap between human perception of color and the precise language computers understand. Understanding how these colors are defined and rendered reveals a fascinating interplay of art and engineering.

The Language of Web Colors

Imagine painting a masterpiece, but instead of brushes and pigments, you're using lines of code. That's essentially what web designers do with web colors. These are the specific color definitions used to display pages across the World Wide Web, ensuring that the 'red' you see is the 'red' someone else sees, no matter their device.

At their core, web colors are typically described using the RGB color model. This model defines colors by combining varying intensities of Red, Green, and Blue light. Think of it like the tiny red, green, and blue pixels on your screen lighting up to create every color you perceive.

Defining Colors: Three Key Methods

There are three primary ways to specify a color for the web. You can use common English names, like 'red' or 'blue'. However, for precise control, designers turn to numerical methods: the RGB triplet or, most commonly, its hexadecimal format, often called a hex triplet.

The hexadecimal format is especially powerful because it allows for 24 bits of information to define a color. This means each of the Red, Green, and Blue components can have 256 different intensity levels. Multiply those possibilities together (256 x 256 x 256), and you get over 16.7 million unique colors!

The Hex Triplet Explained

A hex triplet is a six-digit hexadecimal number, prefixed with a '#' symbol, that directly translates to the Red, Green, and Blue values of a color. Each pair of digits represents one color component. For instance, #RRGGBB, where 'RR' is Red, 'GG' is Green, and 'BB' is Blue.

Each pair of hexadecimal digits ranges from '00' (least intense, or off) to 'FF' (most intense, or full brightness). In decimal terms, this is 0 to 255. So, pure red is #FF0000, pure green is #00FF00, and pure blue is #0000FF. Black is #000000 and white is #FFFFFF.

Let's take a real-world example: a hardwood brown color with Red=123, Green=58, and Blue=30. Converting these decimal values to hexadecimal gives us 7B for Red, 3A for Green, and 1E for Blue. Concatenated, the hex triplet becomes #7B3A1E.

The Alpha Channel: Adding Transparency

Sometimes, you need more than just color — you need transparency! Modern web standards also allow for an optional fourth byte in the hex code, representing the 'alpha channel'. This extends the code to eight digits, like #RRGGBBAA, where 'AA' controls the opacity, from fully transparent (00) to fully opaque (FF).

Shorthand Hex: A Convenient Abbreviation

For certain colors, a shorthand three-digit hex code can be used, like #F0C. This is expanded by repeating each digit, turning it into #FF00CC. While convenient, this limits your palette significantly, reducing the available colors from over 16 million to just 4,096.

From Numbers to Names: HTML Color Keywords

Beyond the precise numbers, web developers can also use predefined color names. The initial HTML 4.01 specification, ratified in 1999, defined 16 basic colors — names like 'red', 'green', 'blue', 'black', and 'white' — which were based on the standard VGA palette used in early Windows systems.

Over time, the list of recognized color names expanded dramatically. These 'extended colors' came from merging specifications across HTML, CSS, and SVG. Many were adopted from the X11 color names used in early Unix-like operating systems, leading to a much richer vocabulary for designers.

CSS and the Evolution of Color

Cascading Style Sheets (CSS) revolutionized how we style web pages, including how we define colors. CSS initially recognized the 16 HTML colors plus an additional 124 colors from the Netscape X11 list, bringing the total to 140 named colors for web designers.

Modern CSS specifications have pushed the boundaries even further. CSS Color Level 4, for instance, introduced new color formats and the ability to mix colors in non-sRGB color spaces. This is crucial for creating smooth color gradients and handling colors more accurately across different displays.

Beyond hex codes and named colors, CSS allows direct RGB and RGBA function calls. The rgba() function is particularly powerful, letting you specify the red, green, blue components, and crucially, an alpha (A) value for transparency. This A value is typically a number between 0 (fully transparent) and 1 (fully opaque).

\text{rgb(R, G, B)} \quad \text{or} \quad \text{rgba(R, G, B, A)}
Beyond sRGB: Device-Independent Color

The digital world is vast, and not all screens display colors the same way. Newer CSS specifications like Color 4 and 5 are introducing 'device-independent' color formats. These include advanced models like CIE Lab and OKLab, which aim to represent colors based on human perception, rather than a specific display technology.

These standards also embrace RGB spaces with wider 'gamuts' — a gamut is the full range of colors a device can produce. This means web developers can now specify colors from professional photography and video standards, like those used in cinematic displays, leading to richer, more vibrant web experiences.

Display P3 Prophoto REC.2020 Adobe 1998 RGB

And in a touching tribute, the color 'RebeccaPurple' was added to the CSS Color Level 4 specification in 2014, commemorating Eric Meyer's daughter, Rebecca, who passed away too soon. It's a reminder that even in technical standards, there can be a human touch.

The Fading Era of 'Web-Safe' Colors

Rewind to the mid-1990s, when computer displays were vastly different. Many could only show 256 colors at a time. If a website tried to display a color not in that limited palette, the browser would 'dither' it — essentially approximating the color by mixing dots of available colors, often resulting in a grainy appearance.

To combat this, the concept of 'web-safe' colors emerged. This was a specific palette of 216 colors (a 6x6x6 cube of red, green, and blue values) chosen because they were thought to be reliably displayed without dithering across most 256-color systems. Each color component could only be one of six values: 00, 33, 66, 99, CC, or FF in hexadecimal.

However, the 'web-safe' palette had its flaws. It offered a limited range of lighter colors for backgrounds, and the darkest colors were often indistinguishable. With the widespread adoption of 24-bit 'TrueColor' displays, capable of showing millions of colors simultaneously, the need for web-safe colors largely disappeared. It's a fascinating artifact of early web development, showcasing the clever solutions devised for the technological limitations of the time.

Article

Web colors

Web colors are colors used in displaying web pages on the World Wide Web; they can be described by way of three methods: a color may be specified as an RGB triplet, in hexadecimal format (a hex triplet) or according to its common English name in some cases. A color tool or other graphics software is often used to generate color values. In some uses, hexadecimal color codes are specified with notation using a leading number sign (#). A color is specified according to the intensity of its red, green and blue components, each represented by eight bits. Thus, there are 24 bits used to specify a web color within the sRGB gamut, and 16,777,216 colors that may be so specified. In hexadecimal, these are specified with two hexadecimal digits per color, leading to a total of six hexadecimal digits. In some contexts, it is possible to specify two more place values, which provide a transparency (alpha) channel.

Colors outside the sRGB gamut can be specified in Cascading Style Sheets by making one or more of the red, green and blue components negative or greater than 100%, so the color space is theoretically an unbounded extrapolation of sRGB similar to scRGB. Specifying a non-sRGB color this way requires the RGB() function call. It is impossible with the hexadecimal syntax (and thus impossible in legacy HTML documents that do not use CSS).

The first versions of Mosaic and Netscape Navigator used the X11 color names as the basis for their color lists, as both started as X Window System applications. Web colors have an unambiguous colorimetric definition, sRGB, which relates the chromaticities of a particular phosphor set, a given transfer curve, adaptive whitepoint, and viewing conditions. These have been chosen to be similar to many real-world monitors and viewing conditions, to allow rendering to be fairly close to the specified values even without color management. User agents vary in the fidelity with which they represent the specified colors. More advanced user agents use color management to provide better color fidelity; this is particularly important for Web-to-print applications.

Hex triplet

Web colors

A hex triplet is a six-digit (or eight-digit), three-byte (or four-byte) hexadecimal number used in HTML, CSS, SVG, and other computing applications to represent colors. The bytes represent the red, green, and blue components of the color. (The optional fourth byte refers to alpha channel.) One byte represents a number in the range 00 to FF (in hexadecimal notation), or 0 to 255 in decimal notation. This represents the lowest (0) to the highest (255) intensity of each of the color components. Thus web colors specify colors in the 24-bit RGB color scheme. The hex triplet is formed by concatenating three bytes in hexadecimal notation, in the following order:

• Byte 1: red value (color type red) • Byte 2: green value (color type green) • Byte 3: blue value (color type blue) • Byte 4 (optional): alpha value

For example, consider the color where the red/green/blue values are decimal numbers: red=123, green=58, blue=30 (a hardwood brown color). The decimal numbers 123, 58, and 30 are equivalent to the hexadecimal numbers 7B, 3A, and 1E, respectively. The hex triplet is obtained by concatenating the six hexadecimal digits together, 7B3A1E in this example.

If any one of the three color values is less than 10 hex (16 decimal), it must be represented with a leading zero so that the triplet always has exactly six digits. For example, the decimal triplet 4, 8, 16 would be represented by the hex digits 04, 08, 10, forming the hex triplet 040810.

The number of colors that can be represented by this system is 2563, 166, or 224 = 16,777,216.

Shorthand hexadecimal form

An abbreviated, three (hexadecimal)-digit or four-digit form can be used, but can cause errors if software or maintenance scripts are only expecting the long form. Expanding this form to the six-digit form is as simple as repeating each digit: 09C becomes 0099CC as presented on the following CSS example:

This shorthand form reduces the palette to 4,096 colors, equivalent of 12-bit color as opposed to 24-bit color using the whole six-digit form (16,777,216 colors). This limitation is sufficient for many text-based documents.

Converting RGB to hexadecimal

RGB values are usually given in the 0–255 range; if they are in the 0–1 range, the values are multiplied by 255 before conversion. This number divided by sixteen (integer division; ignoring any remainder) gives the first hexadecimal digit (between 0 and F, where the letters A to F represent the numbers 10 to 15. See hexadecimal for more details). The remainder gives the second hexadecimal digit. For instance, the RGB value 58 (as shown in the previous example of hex triplets) divides into 3 groups of 16, thus the first digit is 3. A remainder of ten gives the hexadecimal number 3A. Likewise, the RGB value 201 divides into 12 groups of 16, thus the first digit is C. A remainder of nine gives the hexadecimal number C9. This process is repeated for each of the three color values.

Conversion between number bases is a common feature of calculators, including both hand-held models and the software calculators bundled with most modern operating systems. Web-based tools specifically for converting color values are also available.

HTML color names

Web colors

Recent W3C specifications of color names distinguishes between basic and extended colors. In HTML and XHTML, colors can be used for text, background color, frame borders, tables, and individual table cells.

A Diagram containing every basic HTML color

Basic colors

The basic colors are 16 colors defined in the HTML 4.01 specification, ratified in 1999, as follows (names are defined in this context to be case-insensitive):

These 16 were labeled as sRGB and included in the HTML 3.0 specification, which noted they were "the standard 16 colors supported with the Windows VGA palette."

Extended colors

SVG Version of X11 color names

SVG1.1 named colors with sRGB hex/dec and HSL codes, at UHD (4K) resolution

Extended colors are the result of merging specifications from HTML 4.01, CSS 2.0, SVG 1.0 and CSS3 User Interfaces (CSS3 UI).

Several colors are defined by web browsers. A particular browser may not recognize all of these colors, but as of 2005, all modern, general-use, graphical browsers support the full list of colors. Many of these colors are from the list of X11 color names distributed with the X Window System. These colors were standardized by SVG 1.0, and are accepted by SVG Full user agents. They are not part of SVG Tiny.

The list of colors shipped with the X11 product varies between implementations and clashes with certain of the HTML names such as green. X11 colors are defined as simple RGB (hence, no particular color space), rather than sRGB. This means that the list of colors found in X11 (e.g., in /usr/lib/X11/rgb.txt) should not directly be used to choose colors for the web.

The list of web "X11 colors" from the CSS3 specification, along with their hexadecimal and decimal equivalents, is shown below. Compare the alphabetical lists in the W3C standards. This includes the common synonyms: aqua (HTML4/CSS 1.0 standard name) and cyan (common sRGB name), fuchsia (HTML4/CSS 1.0 standard name) and magenta (common sRGB name), gray (HTML4/CSS 1.0 standard name) and grey.

<table><thead><tr><th>HTML name</th><th>R G B</th></tr></thead><tbody><tr><td>Hex</td><td>Decimal</td></tr><tr><td>Pink colors</td></tr><tr><td>MediumVioletRed</td><td>C71585</td><td>199, 21, 133</td></tr><tr><td>DeepPink</td><td>FF1493</td><td>255, 20, 147</td></tr><tr><td>PaleVioletRed</td><td>DB7093</td><td>219, 112, 147</td></tr><tr><td>HotPink</td><td>FF69B4</td><td>255, 105, 180</td></tr><tr><td>LightPink</td><td>FFB6C1</td><td>255, 182, 193</td></tr><tr><td>Pink</td><td>FFC0CB</td><td>255, 192, 203</td></tr><tr><td>Red colors</td></tr><tr><td>DarkRed</td><td>8B0000</td><td>139, 0, 0</td></tr><tr><td>Red</td><td>FF0000</td><td>255, 0, 0</td></tr><tr><td>Firebrick</td><td>B22222</td><td>178, 34, 34</td></tr><tr><td>Crimson</td><td>DC143C</td><td>220, 20, 60</td></tr><tr><td>IndianRed</td><td>CD5C5C</td><td>205, 92, 92</td></tr><tr><td>LightCoral</td><td>F08080</td><td>240, 128, 128</td></tr><tr><td>Salmon</td><td>FA8072</td><td>250, 128, 114</td></tr><tr><td>DarkSalmon</td><td>E9967A</td><td>233, 150, 122</td></tr><tr><td>LightSalmon</td><td>FFA07A</td><td>255, 160, 122</td></tr><tr><td>Orange colors</td></tr><tr><td>OrangeRed</td><td>FF4500</td><td>255, 69, 0</td></tr><tr><td>Tomato</td><td>FF6347</td><td>255, 99, 71</td></tr><tr><td>DarkOrange</td><td>FF8C00</td><td>255, 140, 0</td></tr><tr><td>Coral</td><td>FF7F50</td><td>255, 127, 80</td></tr><tr><td>Orange</td><td>FFA500</td><td>255, 165, 0</td></tr><tr><td>Yellow colors</td></tr><tr><td>DarkKhaki</td><td>BDB76B</td><td>189, 183, 107</td></tr><tr><td>Gold</td><td>FFD700</td><td>255, 215, 0</td></tr><tr><td>Khaki</td><td>F0E68C</td><td>240, 230, 140</td></tr><tr><td>PeachPuff</td><td>FFDAB9</td><td>255, 218, 185</td></tr><tr><td>Yellow</td><td>FFFF00</td><td>255, 255, 0</td></tr><tr><td>PaleGoldenrod</td><td>EEE8AA</td><td>238, 232, 170</td></tr><tr><td>Moccasin</td><td>FFE4B5</td><td>255, 228, 181</td></tr><tr><td>PapayaWhip</td><td>FFEFD5</td><td>255, 239, 213</td></tr><tr><td>LightGoldenrodYellow</td><td>FAFAD2</td><td>250, 250, 210</td></tr><tr><td>LemonChiffon</td><td>FFFACD</td><td>255, 250, 205</td></tr><tr><td>LightYellow</td><td>FFFFE0</td><td>255, 255, 224</td></tr><tr><td>Brown colors</td></tr><tr><td>Maroon</td><td>800000</td><td>128, 0, 0</td></tr><tr><td>Brown</td><td>A52A2A</td><td>165, 42, 42</td></tr><tr><td>SaddleBrown</td><td>8B4513</td><td>139, 69, 19</td></tr><tr><td>Sienna</td><td>A0522D</td><td>160, 82, 45</td></tr><tr><td>Chocolate</td><td>D2691E</td><td>210, 105, 30</td></tr><tr><td>DarkGoldenrod</td><td>B8860B</td><td>184, 134, 11</td></tr><tr><td>Peru</td><td>CD853F</td><td>205, 133, 63</td></tr><tr><td>RosyBrown</td><td>BC8F8F</td><td>188, 143, 143</td></tr><tr><td>Goldenrod</td><td>DAA520</td><td>218, 165, 32</td></tr><tr><td>SandyBrown</td><td>F4A460</td><td>244, 164, 96</td></tr><tr><td>Tan</td><td>D2B48C</td><td>210, 180, 140</td></tr><tr><td>Burlywood</td><td>DEB887</td><td>222, 184, 135</td></tr><tr><td>Wheat</td><td>F5DEB3</td><td>245, 222, 179</td></tr><tr><td>NavajoWhite</td><td>FFDEAD</td><td>255, 222, 173</td></tr><tr><td>Bisque</td><td>FFE4C4</td><td>255, 228, 196</td></tr><tr><td>BlanchedAlmond</td><td>FFEBCD</td><td>255, 235, 205</td></tr><tr><td>Cornsilk</td><td>FFF8DC</td><td>255, 248, 220</td></tr></tbody></table>

<table><thead><tr><th>HTML name</th><th>R G B</th></tr></thead><tbody><tr><td>Hex</td><td>Decimal</td></tr><tr><td>Purple, violet, and magenta colors</td></tr><tr><td>Indigo</td><td>4B0082</td><td>75, 0, 130</td></tr><tr><td>Purple</td><td>800080</td><td>128, 0, 128</td></tr><tr><td>DarkMagenta</td><td>8B008B</td><td>139, 0, 139</td></tr><tr><td>DarkViolet</td><td>9400D3</td><td>148, 0, 211</td></tr><tr><td>DarkSlateBlue</td><td>483D8B</td><td>72, 61, 139</td></tr><tr><td>BlueViolet</td><td>8A2BE2</td><td>138, 43, 226</td></tr><tr><td>DarkOrchid</td><td>9932CC</td><td>153, 50, 204</td></tr><tr><td>Fuchsia</td><td>FF00FF</td><td>255, 0, 255</td></tr><tr><td>Magenta</td><td>FF00FF</td><td>255, 0, 255</td></tr><tr><td>SlateBlue</td><td>6A5ACD</td><td>106, 90, 205</td></tr><tr><td>MediumSlateBlue</td><td>7B68EE</td><td>123, 104, 238</td></tr><tr><td>MediumOrchid</td><td>BA55D3</td><td>186, 85, 211</td></tr><tr><td>MediumPurple</td><td>9370DB</td><td>147, 112, 219</td></tr><tr><td>Orchid</td><td>DA70D6</td><td>218, 112, 214</td></tr><tr><td>Violet</td><td>EE82EE</td><td>238, 130, 238</td></tr><tr><td>Plum</td><td>DDA0DD</td><td>221, 160, 221</td></tr><tr><td>Thistle</td><td>D8BFD8</td><td>216, 191, 216</td></tr><tr><td>Lavender</td><td>E6E6FA</td><td>230, 230, 250</td></tr><tr><td>Blue colors</td></tr><tr><td>MidnightBlue</td><td>191970</td><td>25, 25, 112</td></tr><tr><td>Navy</td><td>000080</td><td>0, 0, 128</td></tr><tr><td>DarkBlue</td><td>00008B</td><td>0, 0, 139</td></tr><tr><td>MediumBlue</td><td>0000CD</td><td>0, 0, 205</td></tr><tr><td>Blue</td><td>0000FF</td><td>0, 0, 255</td></tr><tr><td>RoyalBlue</td><td>4169E1</td><td>65, 105, 225</td></tr><tr><td>SteelBlue</td><td>4682B4</td><td>70, 130, 180</td></tr><tr><td>DodgerBlue</td><td>1E90FF</td><td>30, 144, 255</td></tr><tr><td>DeepSkyBlue</td><td>00BFFF</td><td>0, 191, 255</td></tr><tr><td>CornflowerBlue</td><td>6495ED</td><td>100, 149, 237</td></tr><tr><td>SkyBlue</td><td>87CEEB</td><td>135, 206, 235</td></tr><tr><td>LightSkyBlue</td><td>87CEFA</td><td>135, 206, 250</td></tr><tr><td>LightSteelBlue</td><td>B0C4DE</td><td>176, 196, 222</td></tr><tr><td>LightBlue</td><td>ADD8E6</td><td>173, 216, 230</td></tr><tr><td>PowderBlue</td><td>B0E0E6</td><td>176, 224, 230</td></tr><tr><td>Cyan colors</td></tr><tr><td>Teal</td><td>008080</td><td>0, 128, 128</td></tr><tr><td>DarkCyan</td><td>008B8B</td><td>0, 139, 139</td></tr><tr><td>LightSeaGreen</td><td>20B2AA</td><td>32, 178, 170</td></tr><tr><td>CadetBlue</td><td>5F9EA0</td><td>95, 158, 160</td></tr><tr><td>DarkTurquoise</td><td>00CED1</td><td>0, 206, 209</td></tr><tr><td>MediumTurquoise</td><td>48D1CC</td><td>72, 209, 204</td></tr><tr><td>Turquoise</td><td>40E0D0</td><td>64, 224, 208</td></tr><tr><td>Aqua</td><td>00FFFF</td><td>0, 255, 255</td></tr><tr><td>Cyan</td><td>00FFFF</td><td>0, 255, 255</td></tr><tr><td>Aquamarine</td><td>7FFFD4</td><td>127, 255, 212</td></tr><tr><td>PaleTurquoise</td><td>AFEEEE</td><td>175, 238, 238</td></tr><tr><td>LightCyan</td><td>E0FFFF</td><td>224, 255, 255</td></tr></tbody></table>

<table><thead><tr><th>HTML name</th><th>R G B</th></tr></thead><tbody><tr><td>Hex</td><td>Decimal</td></tr><tr><td>Green colors</td></tr><tr><td>DarkGreen</td><td>006400</td><td>0, 100, 0</td></tr><tr><td>Green</td><td>008000</td><td>0, 128, 0</td></tr><tr><td>DarkOliveGreen</td><td>556B2F</td><td>85, 107, 47</td></tr><tr><td>ForestGreen</td><td>228B22</td><td>34, 139, 34</td></tr><tr><td>SeaGreen</td><td>2E8B57</td><td>46, 139, 87</td></tr><tr><td>Olive</td><td>808000</td><td>128, 128, 0</td></tr><tr><td>OliveDrab</td><td>6B8E23</td><td>107, 142, 35</td></tr><tr><td>MediumSeaGreen</td><td>3CB371</td><td>60, 179, 113</td></tr><tr><td>LimeGreen</td><td>32CD32</td><td>50, 205, 50</td></tr><tr><td>Lime</td><td>00FF00</td><td>0, 255, 0</td></tr><tr><td>SpringGreen</td><td>00FF7F</td><td>0, 255, 127</td></tr><tr><td>MediumSpringGreen</td><td>00FA9A</td><td>0, 250, 154</td></tr><tr><td>DarkSeaGreen</td><td>8FBC8F</td><td>143, 188, 143</td></tr><tr><td>MediumAquamarine</td><td>66CDAA</td><td>102, 205, 170</td></tr><tr><td>YellowGreen</td><td>9ACD32</td><td>154, 205, 50</td></tr><tr><td>LawnGreen</td><td>7CFC00</td><td>124, 252, 0</td></tr><tr><td>Chartreuse</td><td>7FFF00</td><td>127, 255, 0</td></tr><tr><td>LightGreen</td><td>90EE90</td><td>144, 238, 144</td></tr><tr><td>GreenYellow</td><td>ADFF2F</td><td>173, 255, 47</td></tr><tr><td>PaleGreen</td><td>98FB98</td><td>152, 251, 152</td></tr><tr><td>White colors</td></tr><tr><td>MistyRose</td><td>FFE4E1</td><td>255, 228, 225</td></tr><tr><td>AntiqueWhite</td><td>FAEBD7</td><td>250, 235, 215</td></tr><tr><td>Linen</td><td>FAF0E6</td><td>250, 240, 230</td></tr><tr><td>Beige</td><td>F5F5DC</td><td>245, 245, 220</td></tr><tr><td>WhiteSmoke</td><td>F5F5F5</td><td>245, 245, 245</td></tr><tr><td>LavenderBlush</td><td>FFF0F5</td><td>255, 240, 245</td></tr><tr><td>OldLace</td><td>FDF5E6</td><td>253, 245, 230</td></tr><tr><td>AliceBlue</td><td>F0F8FF</td><td>240, 248, 255</td></tr><tr><td>Seashell</td><td>FFF5EE</td><td>255, 245, 238</td></tr><tr><td>GhostWhite</td><td>F8F8FF</td><td>248, 248, 255</td></tr><tr><td>Honeydew</td><td>F0FFF0</td><td>240, 255, 240</td></tr><tr><td>FloralWhite</td><td>FFFAF0</td><td>255, 250, 240</td></tr><tr><td>Azure</td><td>F0FFFF</td><td>240, 255, 255</td></tr><tr><td>MintCream</td><td>F5FFFA</td><td>245, 255, 250</td></tr><tr><td>Snow</td><td>FFFAFA</td><td>255, 250, 250</td></tr><tr><td>Ivory</td><td>FFFFF0</td><td>255, 255, 240</td></tr><tr><td>White</td><td>FFFFFF</td><td>255, 255, 255</td></tr><tr><td>Gray and black colors</td></tr><tr><td>Black</td><td>000000</td><td>0, 0, 0</td></tr><tr><td>DarkSlateGray</td><td>2F4F4F</td><td>47, 79, 79</td></tr><tr><td>DimGray</td><td>696969</td><td>105, 105, 105</td></tr><tr><td>SlateGray</td><td>708090</td><td>112, 128, 144</td></tr><tr><td>Gray</td><td>808080</td><td>128, 128, 128</td></tr><tr><td>LightSlateGray</td><td>778899</td><td>119, 136, 153</td></tr><tr><td>DarkGray</td><td>A9A9A9</td><td>169, 169, 169</td></tr><tr><td>Silver</td><td>C0C0C0</td><td>192, 192, 192</td></tr><tr><td>LightGray</td><td>D3D3D3</td><td>211, 211, 211</td></tr><tr><td>Gainsboro</td><td>DCDCDC</td><td>220, 220, 220</td></tr></tbody></table>

CSS colors

Web colors

The Cascading Style Sheets specification defines the same number of named colors as the HTML 4 spec, namely the 16 HTML colors, and 124 colors from the Netscape X11 color list for a total of 140 names that were recognized by Internet Explorer (IE) 3.0 and Netscape Navigator 3.0. Blooberry.com notes that Opera 2.1 and Safari 1 also included Netscape's expanded list of 140 color names, but later discovered 14 names not included with Opera 3.5 on Windows 98.

In CSS 2.1, the color 'orange' (one of the 140) was added to the section with the 16 HTML4 colors as a 17th color. The CSS3.0 specification did not include orange in the "HTML4 color keywords" section, which was renamed as "Basic color keywords". In the same reference, the "SVG color keywords" section, was renamed "Extended color keywords", after starting out as "X11 color keywords" in an earlier working draft. The working draft for the level 4 color module combines the Basic and Extended sections together in a simple "Named Colors" section.

CSS 2, SVG and CSS 2.1 allow web authors to use system colors, which are color names whose values are taken from the operating system, picking the operating system's highlighted text color, or the background color for tooltip controls. This enables web authors to style their content in line with the operating system of the user agent. The CSS3 color module has deprecated the use of system colors in favor of CSS3 UI System Appearance property, which itself was subsequently dropped from CSS3.

<table><thead><tr><th>Appearance</th><th>Keyword</th></tr></thead><tbody><tr><td></td><td>linkText</td></tr><tr><td></td><td>visitedText</td></tr><tr><td></td><td>activeText</td></tr><tr><td></td><td>highlight</td></tr><tr><td></td><td>mark</td></tr></tbody></table>

The CSS3 specification also introduces HSL color space values to style sheets:

CSS also supports the special color transparent, which represents an alpha value of zero; by default, transparent is rendered as an invisible nominal black: rgba(0, 0, 0, 0). It was introduced in CSS1 but its scope of use has expanded over the versions.

CSS Color 4

Level 4 of the CSS Color specification introduced several new CSS color formats.

Besides new ways to write colors, it also introduces the concept of mixing colors in a non-sRGB color space, a first step towards fixing a well-known issue in color gradients. Some sections explaining color theory and common operations like gamut mapping are also added to aid implementation.

Device independent color

CSS Color 4 introduces several different formats for device independent color that can display the entirety of visible color (in a capable screen), including:

• CIE Lab and LCH • OKLab and OKLCH (preferred over Lab/LCH) • XYZ (D50 or D65 [default])

Predefined color spaces

A number of RGB spaces with gamuts that are wider than sRGB are also introduced through the new color() function:

• Display P3 • Prophoto • REC.2020 • Adobe 1998 RGB

A linearized variant of sRGB is also defined for color mixing.

Other formats

On 21 June 2014, the CSS WG added the color RebeccaPurple to the Editor's Draft of the Colors module level 4, to commemorate Eric Meyer's daughter Rebecca, who died on 7 June 2014, her sixth birthday.

CSS4 also introduces the HWB color model as an alternative to HSL/HSV.

CSS Color 5

The draft CSS Color 5 specification introduces syntax for mixing and manipulating existing colors, including:

• A color-mix() function for mixing colors • Relative color syntax for manipulating components of an existing color

Custom color spaces are also supported via ICC profiles. This allows the use of CMYK on web pages.

Web-safe colors

Web colors

In the mid-1990s, many displays were only capable of displaying 256 colors, dictated by the hardware or changeable by a "color table". When a color was found (e.g., in an image) that was not available, a different one had to be used. This was done by either using the closest color or by using dithering.

There were various attempts to make a "standard" color palette. A set of colors was needed that could be shown without dithering on 256-color displays; the number 216 was chosen partly because computer operating systems customarily reserved sixteen to twenty colors for their own use; it was also selected because it allowed exactly six equally spaced shades of red, green, and blue (6 × 6 × 6 = 216), each from 00 to FF (including both limits).

The list of colors was presented as if it had special properties that render it immune to dithering, but on 256-color displays applications could actually set a palette of any selection of colors that they chose, dithering the rest. These colors were chosen specifically because they matched the palettes selected by various browser applications. There were not very different palettes in use in different browsers.

"Web-safe" colors had a flaw in that, on systems such as X11 where the palette is shared between applications, smaller color cubes (5×5×5 or 4×4×4) were allocated by browsers—the "web-safe" colors would dither on such systems. Different results were obtained by providing an image with a larger range of colors and allowing the browser to quantize the color space if needed, rather than suffer the quality loss of a double quantization.

Through the 2000s, use of 256-color displays in personal computers dropped sharply in favour of 24-bit (TrueColor) displays, and "web-safe" colors are no longer commonly used on the web.

The "web-safe" colors do not all have standard names, but each can be specified by an RGB triplet: each component (red, green, and blue) takes one of the six values from the following table (out of the 256 possible values available for each component in full 24-bit color).

<table><thead><tr><th>Key</th><th>Hex</th><th>Decimal</th><th>Fraction</th></tr></thead><tbody><tr><td>0</td><td>00</td><td>0</td><td>0</td></tr><tr><td>3</td><td>33</td><td>51</td><td>0.2</td></tr><tr><td>6</td><td>66</td><td>102</td><td>0.4</td></tr><tr><td>9</td><td>99</td><td>153</td><td>0.6</td></tr><tr><td>C (12)</td><td>CC</td><td>204</td><td>0.8</td></tr><tr><td>F (15)</td><td>FF</td><td>255</td><td>1</td></tr></tbody></table>

The following table shows all of the "web-safe" colors. One shortcoming of the web-safe palette is its small range of light colors for webpage backgrounds, whereas the intensities at the low end of the range, such as the two darkest, are similar to each other, making them hard to distinguish. Values flanked by "" (asterisk) are part of the "really safe palette;" see Safest web colors, below.

Color table

<table><thead><tr><th>000</th><th>300</th><th>600</th><th>900</th><th>C00</th><th>F00</th></tr></thead><tbody><tr><td>003</td><td>303</td><td>603</td><td>903</td><td>C03</td><td>F03</td></tr><tr><td>006</td><td>306</td><td>606</td><td>906</td><td>C06</td><td>F06</td></tr><tr><td>009</td><td>309</td><td>609</td><td>909</td><td>C09</td><td>F09</td></tr><tr><td>00C</td><td>30C</td><td>60C</td><td>90C</td><td>C0C</td><td>F0C</td></tr><tr><td>00F</td><td>30F</td><td>60F</td><td>90F</td><td>C0F</td><td>F0F</td></tr><tr><td>030</td><td>330</td><td>630</td><td>930</td><td>C30</td><td>F30</td></tr><tr><td>033</td><td>333</td><td>633</td><td>933</td><td>C33</td><td>F33</td></tr><tr><td>036</td><td>336</td><td>636</td><td>936</td><td>C36</td><td>F36</td></tr><tr><td>039</td><td>339</td><td>639</td><td>939</td><td>C39</td><td>F39</td></tr><tr><td>03C</td><td>33C</td><td>63C</td><td>93C</td><td>C3C</td><td>F3C</td></tr><tr><td>03F</td><td>33F</td><td>63F</td><td>93F</td><td>C3F</td><td>F3F</td></tr><tr><td>060</td><td>360</td><td>660</td><td>960</td><td>C60</td><td>F60</td></tr><tr><td>063</td><td>363</td><td>663</td><td>963</td><td>C63</td><td>F63</td></tr><tr><td>066</td><td>366</td><td>666</td><td>966</td><td>C66</td><td>F66</td></tr><tr><td>069</td><td>369</td><td>669</td><td>969</td><td>C69</td><td>F69</td></tr><tr><td>06C</td><td>36C</td><td>66C</td><td>96C</td><td>C6C</td><td>F6C</td></tr><tr><td>06F</td><td>36F</td><td>66F</td><td>96F</td><td>C6F</td><td>F6F</td></tr><tr><td>090</td><td>390</td><td>690</td><td>990</td><td>C90</td><td>F90</td></tr><tr><td>093</td><td>393</td><td>693</td><td>993</td><td>C93</td><td>F93</td></tr><tr><td>096</td><td>396</td><td>696</td><td>996</td><td>C96</td><td>F96</td></tr><tr><td>099</td><td>399</td><td>699</td><td>999</td><td>C99</td><td>F99</td></tr><tr><td>09C</td><td>39C</td><td>69C</td><td>99C</td><td>C9C</td><td>F9C</td></tr><tr><td>09F</td><td>39F</td><td>69F</td><td>99F</td><td>C9F</td><td>F9F</td></tr><tr><td>0C0</td><td>3C0</td><td>6C0</td><td>9C0</td><td>CC0</td><td>FC0</td></tr><tr><td>0C3</td><td>3C3</td><td>6C3</td><td>9C3</td><td>CC3</td><td>FC3</td></tr><tr><td>0C6</td><td>3C6</td><td>6C6</td><td>9C6</td><td>CC6</td><td>FC6</td></tr><tr><td>0C9</td><td>3C9</td><td>6C9</td><td>9C9</td><td>CC9</td><td>FC9</td></tr><tr><td>0CC</td><td>3CC</td><td>6CC</td><td>9CC</td><td>CCC</td><td>FCC</td></tr><tr><td>0CF</td><td>3CF</td><td>6CF</td><td>9CF</td><td>CCF</td><td>FCF</td></tr><tr><td>0F0</td><td>3F0</td><td>6F0</td><td>9F0</td><td>CF0</td><td>FF0</td></tr><tr><td>0F3</td><td>3F3</td><td>6F3</td><td>9F3</td><td>CF3</td><td>FF3</td></tr><tr><td>0F6</td><td>3F6</td><td>6F6</td><td>9F6</td><td>CF6</td><td>FF6</td></tr><tr><td>0F9</td><td>3F9</td><td>6F9</td><td>9F9</td><td>CF9</td><td>FF9</td></tr><tr><td>0FC</td><td>3FC</td><td>6FC</td><td>9FC</td><td>CFC</td><td>FFC</td></tr><tr><td>0FF</td><td>3FF</td><td>6FF</td><td>9FF</td><td>CFF</td><td>FFF</td></tr></tbody></table>

Each color code listed is a shorthand for the RGB value. For example, code 609 is equivalent to RGB code 102-0-153 or HEX code #660099.

Safest web colors

Designers were encouraged to stick to these 216 "web-safe" colors in their websites because there were a lot of 8-bit color displays when the 216-color palette was developed. David Lehn and Hadley Stern discovered that only 22 of the 216 colors in the web-safe palette are reliably displayed without inconsistent remapping on 16-bit computer displays. They called these 22 colors "the really safe palette"; it consists largely of shades of green, yellow, and cyan.

<table><thead><tr><th>R---GB</th><th>0</th><th>3</th><th>6</th><th>9</th><th>C</th><th>F</th></tr></thead><tbody><tr><td>00</td><td>000</td><td></td><td></td><td></td><td></td><td>F00</td></tr><tr><td>03</td><td>003</td><td></td><td></td><td></td><td></td><td>F03</td></tr><tr><td>06</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>09</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>0C</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>0F</td><td>00F</td><td></td><td></td><td></td><td></td><td>F0F</td></tr><tr><td>⋮</td><td>⋮</td></tr><tr><td>F0</td><td>0F0</td><td></td><td>6F0</td><td></td><td></td><td>FF0</td></tr><tr><td>F3</td><td></td><td>3F3</td><td>6F3</td><td></td><td></td><td>FF3</td></tr><tr><td>F6</td><td>0F6</td><td>3F6</td><td></td><td></td><td>CF6</td><td>FF6</td></tr><tr><td>F9</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>FC</td><td>0FC</td><td>3FC</td><td></td><td></td><td></td><td></td></tr><tr><td>FF</td><td>0FF</td><td>3FF</td><td>6FF</td><td></td><td></td><td>FFF</td></tr></tbody></table>

Accessibility

Color selection

Some browsers and devices do not support colors. For these displays or blind and colorblind users, Web content depending on colors can be difficult or impossible to use.

Either no colors should be specified (to invoke the browser's default colors), or both the background and all foreground colors (such as the colors of plain text, unvisited links, hovered links, active links, and visited links) should be specified to avoid black on black or white on white effects.

Color contrast

The Web Content Accessibility Guidelines recommend a contrast ratio of at least 4.5:1 between the relative luminance of text and its background color or at least 3:1 for large text. Enhanced accessibility requires contrast ratios greater than 7:1.

However, addressing accessibility concerns is not simply a matter of increasing the contrast ratio. As a report to the Web Accessibility Initiative indicates, dyslexic readers are better served by contrast ratios below the maximum. The recommendations they refer to of off-black (#0A0A0A) on off-white (#FFFFE5) and black (#000000) on creme (#FAFAC8) have contrast ratios of 11.7:1 and 20.3:1 respectively. Among their other color pairs, brown (#282800) on dark green (#A0A000) has a contrast ratio of 3.24:1, which is less than the WCAG recommendation, dark brown (#1E1E00) on light green (#B9B900) has a contrast ratio of 4.54:1 and blue (#00007D) on yellow (#FFFF00) has a contrast ratio of 11.4:1. The colors named in the report use different color values than the web colors of the same name.