[Previous] [Contents] [Next]

Specifying CSS Properties


You specify a property you want by naming the element whose properties you want to set, followed by pairs of property names and values:

Element {property1: value1; property2: value2; }

For example:

BODY { margin: 0;
       font-family: arial, helvetica, sans-serif;
       font-size: 14px;
       color: black; }

If you want to set the same properties for more than one element at the same time, you group them into a single style declaration:

H1, H2, H3, H5 {color: red;}

Going a step further, if you only want properties to apply to an element when it's inside another element, group the elements into a single style declaration but omit the separating comma. For example, with this style declaration:

H1 B { color: red; }

the text inside a B element will only be red if the B element is enclosed in an H1 element:

<DOC>
<H1>This part will be <B>very red</B></H1>
<P>But this part will be <B>totally unaffected</B>
by the declaration.</P>
</DOC>

[Previous] [Contents] [Next]