Each rule consists of a selector and a declaration. The selector begins a CSS
rule and specifies which part of the HTML document the rule will be applied to. The declaration
consists of a number of property/value pairs that set specific properties and
determine how the relevant element will look. In the following example, p is the selector
and everything thereafter is the declaration:
p {
color: blue;
}
As you probably know, p is the HTML tag for a paragraph. Therefore, if we attach this rule
to a web page (see the section ???Adding styles to a web page??? later on in this chapter for
how to do so), the declaration will be applied to any HTML marked up as a paragraph,
thereby setting the color of said paragraphs to blue.
CSS property names are not case sensitive, but it??™s good to be consistent in web
design??”it??™s highly recommended to always use lowercase. Note, though, that
XML is case sensitive, so when using CSS with XHTML documents served with
the proper XHTML MIME type, everything must be consistent. Also, the W3
specifications recommend that CSS style sheets for XHTML should use lowercase
element and attribute names.
AN INTRODUCTION TO WEB DESIGN
11
1
When you write CSS rules, you place the declaration within curly brackets {}. Properties
and values are separated by a colon (:), and property/value pairs are terminated by a semicolon
(;). Technically, you don??™t have to include the final semicolon in a CSS rule, but most
designers consider it good practice to do so.
Pages:
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68