问题
I know and use a few color names like 'white', 'blue', 'red', is there a complete list of colors allowed in HTML/CSS ?
回答1:
There are a plethora of colors listed at http://www.w3schools.com/HTML/html_colornames.asp. There's also a cautionary note at the bottom:
Note: The names above are not a part of the W3C web standard.
The W3C HTML and CSS standards have listed only 16 valid color names: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow.
If you want valid HTML or CSS use the HEX values instead.
回答2:
CSS3-color has the complete 'Extended color keywords' list.
回答3:
The CSS Color Module Level 3, which is a full W3C Recommendation and therefore supersedes CSS2 where they conflict, lists the 16 HTML4 keywords as “Basic color keywords” and the 147 SVG keywords as “Extended color keywords”—the latter set of 147 being a superset of the basic 16, since they’re all included.
So the answer to your question is 147 names long, not 16; W3Schools, not surprisingly, has it wrong. There are also WAY more keywords actually recognized by browsers, but they’re not “allowed” in a legalistic sense even if they are in a practical sense. As a result, there might be slight differences between browsers when handling those keywords, since they haven’t been precisely defined in a specification.
(P.S. If you’re interested in a sortable table of all 147 extended keywords and their various numeric equivalents, I recently published one on my site along with some visualizations of the basic and extended keywords sets: color wheel and distribution chart.)
(P.P.S. The CSS3 Colors module was not a full Recommendation in 2009.)
回答4:
The W3C HTML and CSS standards have listed only 16 valid color names: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow.
From this site:
http://www.w3schools.com/css/css_colornames.asp
回答5:
There are actually 17 "standard" colors, according to W3 spec: http://www.w3.org/TR/CSS2/syndata.html#color-units
In addition, there are some built-in names for system colors: http://www.w3.org/TR/CSS2/ui.html#system-colors
This 2nd set is deprecated in CSS3.
来源:https://stackoverflow.com/questions/1552796/color-names-allowed-in-html-css