The Properties


We have already seen some examples of the color property and the background properties in use. This section defines them more formally and gives more examples.

The Color Property

The color property sets the color of the text of an element. It is the foreground color. It can also set the color of text decorations, which was discussed in Chapter 5, "Fonts," such as underline, as well as borders that have been created with the border properties discussed in Chapter 8, "Space Around Boxes."

Name:

color

Value:

<color>

Initial:

UA specific

Applies to:

all elements

Inherited:

yes

Percentages:

N/A


The property takes one value a color which is specified by one of the methods discussed in the previous section. The following are examples of rules to specify a color for text or a text decoration:

 EM { color: red } P { color: rgb(255, 0, 0) } /* red */ H1 { color: #f00 }          /* also red */ H1 { color: #ff000 }        /* again, red */ 

A color is inherited by child elements. The default color is set in the user's default style sheet, if one exists. Otherwise, the default color depends on the browser.



Cascading Style Sheets(c) Designing for the Web
Cascading Style Sheets: Designing for the Web (3rd Edition)
ISBN: 0321193121
EAN: 2147483647
Year: 2003
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net