HTML and CSS Reference
In-Depth Information
EXAMPLE 14.5 ( CONTINUED )
3
p { line-height: 2;
text-indent: 6%;
font-family:arial;
font-size:18; }
}
</style>
</head>
<body bgcolor="coral">
4
<p id=title>The Color Palette</p>
5
<p> The world is a colorful place. Web browsers display
millions of those colors every day to make the pages seem
real and interesting. Browser colors are displayed in
combinations of red, green, and blue, called RGB. This is a
system of indexing colors by assigning values of 0 to 255 in
each of the three colors, ranging from no saturation (0) to
full saturation (255). Black has a saturation of 0 and
white has a saturation of 255. In HTML documents these
colors are represented as six hexadecimal values, preceded
by a # sign. White is #FFFFFF and black is #000000. </p>
6
<p>
Although there are millions of different combinations of color,
it is best when working with Web pages to use what are
called Web-safe colors. </p>
</body>
</html>
EXPLANATION
1
#title is called an ID selector, a way in the style sheet that we can allow any selector
to use a style. In this example, the title of the page is going to be distinct from the
text in the rest of the page. For example, if the <p> tag is used, it can identify itself
with this ID selector to produce the text style described in the declaration block
(see line 4). If the ID is not used, the rest of the paragraphs will display text as
defined by the rule in line 3. More discussion on ID selectors is presented in the
section “The ID Selector and the ID Attribute” on page 564.
2
Text controls are defined in the rule. The text will be centered, underlined, with
a 22-point, bold Arial font. The spacing between each letter and each word is de-
fined in pixels.
3
When the <p> tag is used, a line height of 2 will produce double-spaced lines. The
first line of each paragraph will be indented by 6% from the left margin.
4
This paragraph is identifying itself with the title ID. This means that for this para-
graph, the style will follow the rule defined after line 1.
5, 6
Both of these paragraphs take on the style provided by the rule in line 3. The re-
sults is shown in Figure 14.6.
Search WWH ::




Custom Search