Home >Web Front-end >CSS Tutorial >Instructions for using CSS color color_Basic tutorial
red
Equivalent to
rgb(255,0,0)
Equal to
rgb(100%,0%,0%)
Equal to
#ff0000
Equivalent to
#f00
There are 17 predetermined colors, they 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.
The three values of rgb are from 0 to 255, 0 is the lowest level, 255 is the highest level, these values can also be percentages.
We usually use base 10, that is, 0-9, but hexadecimal uses base 16, that is, 0 to f.
The length of three or six hexadecimal digits is preceded by the # character. Three lengths are the compressed form of six. For example, #f00 is the compression of ff0000, and #c96 is #cc9966. Three digits are easy to understand, like rgb, the first is red, the second is green, and the third is blue. But six digits gives more color control.
color and background-color
For color, you can use color and background-color. In American English, "color" is not "colour".
Blue background, yellow text:
h1 {
color: yellow;
background-color: blue;
}
These colors may be rough, You can use another color:
body {
font-size: 0.8em;
color: navy;
}
h1 {
color: #ffc;
background-color: #009;
}
You can see that h1 has turned yellow and blue.
Color and background-color can be used in most html elements, including body.