A Complete Guide to Web Design

(やまだぃちぅ) #1
Properties 399

CSS

Properties

Web Design in a Nutshell, eMatter Edition

Some values can be specified as percentages that are relative to the font size or
bounding box of the element. The following example makes the line height 120%
of the element’s font size:


P { line-height: 120% }

Specifying Color


As in HTML tags, there are two methods for specifying color in style sheets: by
name and by numerical values.


By name


You can specify color values by name as follows:


H1 { color: olive }

The CSS1 Specification specifically lists only 16 color names that can be used in
style sheets; they are:


Other names from the complete list of color names may be supported by some
browsers. For the complete list, see “Specifying Color in HTML” in Chapter 5,
HTML Overview).


By RGB values


Within style sheets, RGB colors can be specified in any of the following methods:


H1 { color: #0000FF }
H1 { color: #00F }
H1 { color: rgb(0,0,255) }
H1 { color: rgb(0%, 0%, 100%)

The first method uses three two-digit hexadecimal RGB values (for a complete
explanation, see “Specifying Color in HTML” in Chapter 5). The second method
uses a three-digit syntax, which is essentially converted to the six-digit form by
replicating each digit (therefore, 00F is the same as 0000FF).


The last two methods use a functional notation specifying RGB values as a
comma-separated list of regular values (from 0 to 255) or percentage values (from
0 to 100%). Note that percentage values can use decimals, e.g.,rgb(0%, 50.5%,
33.3%).


Properties


The real meat of style sheets lies in the collection of properties that can be applied
to selected elements. The properties reviewed in this chapter reflect those
provided in the CSS Level 1 specification (CSS1). The CSS Level 2 specification,
released in May 1998, contains many additional properties and additional values
for existing properties (see “What’s New in CSS2” later in this chapter). However,


aqua gray navy silver
black green olive teal
blue lime purple white
fuchsia maroon red yellow
Free download pdf