Web colors

Web colors are colors used in displaying web pages, and the methods for describing and specifying those colors. Colors may be specified as an RGB triplet or in hexadecimal format (a hex triplet) or according to their common English names 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 (#).[1][2] 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.

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.[3] 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.[4] These have been chosen to be similar to many real-world monitors and viewing conditions, in order 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

A hex triplet is a six-digit, three-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. One byte represents a number in the range 00 to FF (in hexadecimal notation), or 0 to 255 in decimal notation. This represents the least (0) to the most (255) intensity of each of the color components. Thus web colors specify colors in the True Color (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)

For example, consider the color where the red/green/blue values are decimal numbers: red=36, green=104, blue=160 (a grayish-blue color). The decimal numbers 36, 104 and 160 are equivalent to the hexadecimal numbers 24, 68 and A0 respectively. The hex triplet is obtained by concatenating the six hexadecimal digits together, 2468A0 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 166 or 2563 or 224 = 16,777,216.

Shorthand hexadecimal form

An abbreviated, three (hexadecimal)-digit form is used.[5] Expanding this form to the six-digit form is as simple as doubling each digit: 09C becomes 0099CC as presented on the following CSS example:

.threedigit { color: #09C;    }
.sixdigit   { color: #0099CC; } /* same color as above */

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 us 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 us the second hexadecimal digit. For instance the RGB value 201 divides into 12 groups of 16, thus the first digit is C. A remainder of nine gives us 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.

Other Languages
العربية: ألوان الويب
azərbaycanca: Veb rəngləri
বাংলা: ওয়েব রঙ
Bân-lâm-gú: Web sek-chhái
беларуская: Колеры HTML
български: Уеб цветове
bosanski: HTML-boje
català: Colors HTML
čeština: Bezpečné barvy
Deutsch: Webfarbe
español: Colores web
Esperanto: Koloroj por TTT
français: Couleur du Web
한국어: 웹 색상
հայերեն: HTML գույներ
हिन्दी: वेब रंग
Bahasa Indonesia: Warna web
Basa Jawa: Werna wèb
ქართული: ვებ-ფერები
Kiswahili: Kigezo:Rangi
македонски: Семрежни бои
Bahasa Melayu: Warna sesawang
нохчийн: Беснаш HTML
norsk: Webfarger
română: Culori web
русский: Цвета HTML
Simple English: Web color
slovenščina: Spletna barva
svenska: HTML-färger
Tagalog: Web kulay
Türkçe: Web renkleri
українська: Кольори HTML
اردو: ویب رنگ
Zazaki: Kodê rengan
中文: 网页颜色
Lingua Franca Nova: Colores de HTML