Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

CSS color units

Color units

The value of color can be a color name (keyword), a RGB value or a hexadecimal value. We will see an  example using the same color but specified in different ways.

Here is the css file (say color-unit.css):

p {
color: olive
}
li {
color: #808000
}
a: link {
color: rgb(128,128,0)
}

This stylesheet specifies same color in three different ways (color name, hex value and rgb value ).

Here is the html file (say color-unit.htm) to which the stylesheet above is applied:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>example of external CSS - color property </title>
<link href="color-unit.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p>We are learning color property of CSS</p>
<ul>
<li>we will learn color property of CSS in this section</li>
</ul>
<a href="#">Click here to learn more</a>
</body>
</html>

Here is how it will look:

Before go in more detail about css color property,in the next page we will see different ways of specifying color

View this example of CSS color unit in a different browser window

Previous: CSS (foreground) color
Next: CSS color inherit