HTML and CSS Reference
In-Depth Information
Figure 1-2. Moving a style from one element to another
Declarations and Keywords
The declaration block contains one or more declarations. A declaration is always for-
matted as a property followed by a colon and then a value followed by a semicolon.
The colon and semicolon can be followed by zero or more spaces. In nearly all cases,
a value is either a single keyword or a space-separated list of one or more keywords that
are permitted for that property. If you use an incorrect property or value in a declaration,
the whole rule will be ignored. Thus, the following two declarations would fail:
brain-size: 2cm; /* unknown property 'brain-size' */
color: ultraviolet; /* unknown value 'ultraviolet' */
In an instance where you can use more than one keyword for a property's value, the
keywords are usually separated by spaces. Not every property can accept multiple key-
words, but many, such as the font property, can. Let's say you want to define medium-
sized Helvetica for paragraph text, as illustrated in Figure 1-3 .
The rule would read as follows:
p {font: medium Helvetica;}
Note the space between medium and Helvetica , each of which is a keyword (the first is
the font's size and the second is the actual font name). The space allows the user agent
to distinguish between the two keywords and apply them correctly. The semicolon
indicates that the declaration has been concluded.
These space-separated words are referred to as keywords because, taken together, they
form the value of the property in question. For instance, consider the following fictional
rule:
rainbow: red orange yellow green blue indigo violet;
There is no such property as rainbow , of course, but the example is useful for illustrative
purposes. The value of rainbow is red orange yellow green blue indigo violet , and
 
Search WWH ::




Custom Search