Forum Moderators: not2easy
5.2. named colors
Colors in CSS3 can be either a number of numerical values or from a number of sets of named values.
These named values are the HTML4 named colors, the SVG color keywords, and the 'tranparent' and 'currentColor' keywords.
HTML4 named colors
Note that CSS2.1 named color orange is missing from this list in the standard.
Is the omission of orange intentional (if so: why?) or is it an oversight ?
SVG color keywords
These are actually the X11 named colors and there are a lot of them. So "bleachedalmond" and "hotpink" are now valid color names along a whole bunch of others.
Orange is included here, so the omission above might not mater all that much as long as browsers implement it all
inherit (CSS2.1)
While this is part of CSS2.1, it never was very popular as the legacy IE versions didn't implement this.
tansparent (CSS2.1)
currentColor
CSS2 System Colors
The CSS2 system colors are now DEPRECATED in favor of the appearance property [w3.org] in the CSS3 User interface module.
Example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>test</title>
<style type="text/css">
* {
padding: 0;
margin: 0;
}
li {
color: black;
}
span {
width: 100px;
height: 100px;
display: inline-block;
}
</style>
</head>
<body>
<ul>
<li>html4 color: <span style="background-color:red">red</span></li>
<li>svg color: <span style="background-color:cornflowerblue">cornflowerblue</span></li>
<li style="background-color: yellow">transparent color:
<span style="border: 1px solid black;background-color:transparent">
transparent background</span></li>
<li>inherit: <span style="border: 1px solid black"><a href="#"
style="text-decoration:none;color:inherit">inherited black link</a></span></li>
<li>currentColor: <span style="color: green; border: 3px solid currentColor">green
border</span></li>
</ul>
</body>
</html>
Support:
currentColor
inherit
need to test SVG colors better.
(pink is too easy)
Graceful fallback:
Mostly one can find a color (be it numeric) that fits the need and use that in the conditional comment.
IE8.js adds support for inherit in IE6 and IE7
Practical use
Named colors are easier to remember than numeric colors. inherit and curentColor can be used to get a color from another setting or from a parent enhancing the code quality of the CSS and facilitating changes once a site is life