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"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>example of external CSS - color property </title>
<link href="color-unit.css" rel="stylesheet" type="text/css" />
<p>We are learning color property of CSS</p>
<li>we will learn color property of CSS in this section</li>
<a href="#">Click here to learn more</a>

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

Follow us on Facebook and Twitter for latest update.