CSS can handle 16,777,216 colors, using first name, RGB value, or hexadecimal code.
red红色
等同于
rgb(255,0,0)
rgb(100%,0%,0%)
#ff0000
#f00
There are 17 predefined colors, which are:
Aqua, black, blue, fuchsia, gray, green, lime, maroon, navy,
Olive, orange, purple, red, silver, teal, white, and yellow.
Transparent is also a correct value.
RGB three values are from 0 to 255,0 is the lowest, 255 is the highest, these values can also be percentages.
We usually use 10 in 0-9, but hexadecimal uses 16, or 0 to F.
Hexadecimal three or six digit lengths are preceded with a # character, and three lengths are six compression forms, such as #f00 is ff0000 compression, #c96是 #cc9966. Three digits are well understood, like RGB, the first is red, the second is green, and the third is blue. But the six-digit number gives more color control.
Color and Background-color
Colors can be used with color and Background-color, is American English "color" is not "colour".
Blue background, yellow text:
h1 {
color: yellow;
background-color: blue;
}
These colors may be coarse and you can use additional chroma:
body {
font-size: 0.8em;
color: navy;
}
h1 {
color: #ffc;
background-color: #009;
}
You can see that H1 has turned yellow and blue, and color and background-color can be used in most HTML elements, including the body.