A CSS color is either a keyword or a numerical specification

According to the W3C, a CSS color is either ajust written differently to allow for differences in
keyword or a numerical specification. That definitionhow browsers handle the CSS.
seems simple. Colors are either keywords orHexadecimal colors are the same RGB color numbers
numbers, but it's a bit more complicated than that.converted to base-16 and written as one long
Color Keywordsnumber. Hexadecimal to RGB color charts make this
Color keywords are exactly what you might thinkeasy to see. They are written:
they are - a list of words (in English) that correspond#RRGGBB
to colors on Web pages. There are 16 HTML 4 colorEach pair of the hexadecimal triplet is a number from
keywords:00 to FF (base-16), which corresponds to 0 - 255 in
• aquadecimal. So the color red is written:
• black#ff0000
• blueCSS 3 Color Numbers
• fuchsiaCSS 3 adds some additional complexity to the color
• graynumbers. In the CSS 3 recommendation, there is:
• green• the transparent keyword
• lime• RGBA color values
• maroon• HSL color values
• navyThe transparent keyword is not exactly new to CSS
• olive3. CSS 1 allowed background-colors to be marked
• purpletransparent. Then CSS 2 extended it to the
• redborder-color property. CSS 3 extends this keyword
• silverto use in any property that uses color values including
• tealthe color property for changing text and foreground
• whitecolors.
• yellowAn RGBA color value allows you to define the
To make things interesting, the W3C reports thatopacity of the color. It is
"orange" is also a color keyword in the CSS 2written:rgba(red,green,blue,opacity)
specification. Perhaps it will get added back into CSSThe final number is an alpha value ranging from 0.0 to
3 before it's finalized.1.0. A color with an alpha value of 0.0 is fully
But it gets more complicated than that, as there'stransparent and an alpha value of 1.0 is fully opaque.
another list of color keywords that you can use.According to the specification, if the user-agent
These colors are often called the Netscape Nameddoesn't support RGBA, it should default to RGB and
Colors because the Netscape browser was the firstignore the alpha value information. However, in
Web browser to define the color keywords andpractice, this doesn't happen and the color value is
support them. The W3C calls this list the "SVG Colorcompletely ignored.
Keywords". But whatever you call it, you need to beHSL color values refer to hue-saturation-lightness
careful when you use these keywords. Internetnumerical codes for colors. They were added to
Explorer doesn't like the different spellings of graysolve some specific problems with RGB colors:
grey.• RGB is hardware-oriented. It references
Colors as NumbersCRTs and assumes that color model for displaying
Okay, so color keywords aren't as simple as theythe colors. Most professional printers are not RGB
appear, but what about numbers - that should bebased, but CMYK and the translation from screen to
fairly simple, right? Wrong. The CSS 2 specificationprint is not always good.
provides for two ways of specifying colors as• RGB is non-intuitive. In other words, most
numbers:people think of colors in reference to the hue (red
• RGBversus yellow), saturation (grey versus red), or
• Hexadecimal RGBlightness (dark red to red to pink) but RGB forces
RGB Color Numbersyou to put the colors in a machine-generated way.
The format of an RGB color numberRed in HSL would be written:hsl(0,100%,50%);
is:rgb(red,green,blue);HSL also has an alpha value notation - HSLA - which
The red,green,blue are numerical values from 0 toallows you to specify opacity with this color notation
255 or percentage values from 0% to 100%. So, thejust like RGBA.
color red is written:rgb(255,0,0)rgb(100%,0%,0%)HSL is not supported by most browsers, so it's a
Hexadecimal Color Numbersgood idea to just remember this notation for the
Hexadecimal color numbers are also RGB - they arefuture.