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!
14.2.2 How Does a Style Sheet Work?
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.
selector { property: value }
declaration block
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.
<head><title>First Style Sheet</title>
<style type="text/css">
h1 { color: saddlebrown } /* rule */
h2 { color: darkblue
<body bgcolor=silver>
<h1> Welcome to my Stylin' Page</h1>
<h2> What do you think?</h2>
Search WWH ::

Custom Search