HTML and CSS Reference
In-Depth Information
(See the section “CSS Program Structure” on page 530 for more on this.) If you are
contending with an older version of your browser, it might just be a good time to
upgrade to a newer model!
A style sheet consists of the style rules that tell your browser how to present a docu-
ment. The rules consist of two parts: a selector—the HTML element you are trying to
stylize—and the
declaration block
—the properties and values that describe the style
for the selector.
FORMAT
selector { property: value }
declaration block
EXAMPLE
H1 { color: blue }
This rule sets the color of the
H2
element to blue:
H2 { color: blue }
A rule, then, consists of two main parts: the
selector
(e.g.,
H2
) and the declaration
block (e.g.,
color: blue
). Example 14.1 demonstrates this simple rule.
EXAMPLE
14.1
<html>
<head><title>First Style Sheet</title>
1
<style type="text/css">
2
h1 { color: saddlebrown } /* rule */
h2 { color: darkblue
}
</style>
</head>
<body bgcolor=silver>
3
<h1>
Welcome to my Stylin' Page</h1>
4
<h2>
What do you think?</h2>
</body>
</html>