CSS Pocket Reference - Eric A. Meyer
CSS Pocket Reference - Eric A. Meyer
Pocket Reference
Eric A. Meyer
4
O'REILLY
Beijing • Cambridge •Farnham •Koln • Paris • Sebastopol • Taipei • Tokyo
CSS Pocket Reference
by Eric A. Meyer
Printing History:
J.).' [6 02]
(C)
Table of Contents
Introduction 1
Rule Structure 1
Selectors 3
Specifying Values 5
Style Precedence 8
Classification of Elements 11
The Cascade 58
Font Properties 60
Color and Background Properties 64
Text Properties 68
Box Properties 72
Classification Properties 86
Units 90
Digitized by the Internet Archive
in 2012
http://archive.org/details/csspocketreferenOOmeye
CSS Pocket Reference
Introduction
Cascading Style Sheets (CSS) is the W3C standard for con-
trolling the visual presentation of web pages. After a short
introduction to the key concepts of CSS, this book provides
an alphabetical reference to all the CSS1 properties, fol-
lowed by a chart that details web browser support for CSS.
Rule Structure
A style sheet consists of one or more rules that describe
how page elements, which typically correspond to particu-
lar HTML tags, should be displayed. Every rule in CSS has
selector declaration
I
I
HI I {color: purple;}
property value
Inline styles
Style information can be specified for an individual ele-
ment using the style attribute within that element's
HTML tag. The value of the style attribute is a standard
style declaration without the curly braces:
<HTMLxHEADxTITLE>Stylin!</TITLE>
<STYLE TYPE="text/css">
Hi {color: purple;}
P {font-size: lOpt; color: gray;}
</STYLE>
</HEAD>
</HTML>
<HEAD>
<STYLE TYPE="text/css">
@import url(mystyles.css);
</STYLE>
</HEAD>
Selectors
Selectors, which identify the elements to which a style
applies, come in a variety of forms:
Element selectors
The simplest kind of selector refers to an HTML ele-
ment by its tag:
Hi {color: purple;}
Selectors
: . :
Contextual selectors
These selectors specify style attributes for HTML ele-
ments based on the context in which they appear. This
contextual selector specifies that bold text within a list-
item is purple:
LI B {color: purple;}
Class selectors
Specific HTML elements can be grouped into a class
using the CLASS attribute:
<Hl CLASS="warning">Danger!</Hl>
<P CLASS="warning">Be careful. .</?>
ID selectors
The HTML ID attribute assigns a unique identifier to a
particular HTML element:
Specifying Values
Proper syntax is required for specifying certain kinds oi CSS
property values. In CSS1, there are five kinds oi piOJ
values: keywords, length values, percentage- values, colors.
and URLs. The "CSS Property Reference" section lists the
acceptable values for CSS1 properties
Keywords
Keywords are explicit values, such as dotted for border
style and xx- large for font -size. Like property names, key-
words aren't case-sensitive.
Length Values
Inches (in)
As you might expect, these are the inches you find on a
ruler in the United States. The mapping from inches to a
monitor or other display device is usually vague at best,
since most systems have no concept of the relation of
their display area to real-world measurements such as
inches. Thus, inches should be used with extreme cau-
tion in screen design.
Specifying Values
Centimeters (cm)
The centimeters you find on rulers the world over.
There are 2.54 centimeters to an inch, and one centime-
ter equals 0.394 inches. Centimeters have the same
Millimeters (m)
There are 10 millimeters to a centimeter, and thus 25.4
millimeters to an inch; 1 millimeter equals 0.0394 inches.
Millimeters have the same mapping issues as inches and
centimeters.
Points (pt)
Points are a standard typographical measure used by
printers, typesetters, and, more recently, word-process-
ing programs. There are 72 points to an inch, so a
capital letter of text set to 12 points should be one-sixth
of an inch tall. For example, {font-size: I8pt;} is equiv-
alent to {font- size: 0.25in;}, assuming proper mapping
of lengths to the display environment.
Picas (pc)
Picas are another unit of typographical measure. A pica
is equivalent to 12 points, which means there are 6 picas
to an inch. Thus, a capital letter of text set to 1 pica
should be a sixth of an inch tall. For example, {font-
size: l.5pc;} should set text to be the same size as the
previous point declaration, assuming proper mapping.
Em -height (em)
This refers to the em-height of a given font. In CSS, the
em-height is set to be equivalent to the height of the
character box for a given font. Ems can set relative sizes
for fonts; for example, l.2em is the same as saying 120%.
X-beigbt(ex)
The x-height of the font describes the height of any low-
er-case character that doesn't have an ascender (i.e.. "d")
Pixels (px)
\ pixel is a small onscreen box defined rathei abstractly
by CSS. in ess terms, pixel is defined to be about the
.1
Percentage Values
Colors
With CSS, there are five ways to specify color values. Four
of them involve determining your own mix of red, green,
or blue beams; the fifth uses keywords:
XRRGGBB
The hex-pair notation familiar to traditional HTML
authors. In this format, the first pair of digits corre-
sponds to the red setting, the second pair to green, and
the third pair to blue. Each pair is in hexadecimal nota-
tion in the range 00 to FF. Thus, "pure" blue is #0000FF,
"pure" red is #FF0000, and so on.
MGB
A shorter form of the six-digit notation. In this format,
each digit is replicated to arrive at an equivalent six-dig-
it value. Thus, #F8C becomes #FF88CC.
Specifying Values
igb (rrr.rr%,ggg.gg%,bbb.bb%)
Specifies RGB values in the range 0% to 100%, with deci-
mal values allowed (e.g., 75.5%). Thus, the value for
black is rgb(0%,0%0%); 'pure" blue is rgb(0%,0%,100%).
igb(rrr,ggg,bbb)
Specifies RGB values in the range to 255- Not coinci-
dental ly, this range is the decimal equivalent of 00 to FF
in hexadecimal. In this format, "pure" green is
keyword
One of 16 recognized keywords based on the original
Windows VGA colors: aqua, black, blue, fuchsia, gray,
green, lime, maroon, navy, olive, purple, red, silver, teal,
white, and yellow. Browsers may recognize other key-
words, but these aren't (as of this writing) found in any
specification and aren't guaranteed to work consistently
between browsers or indeed from version to version in
a single browser.
URLs
URLs aren't often used in style sheets, but when they are,
they have the following format:
url(wrl)
Points to a file, such as a graphic. CSS defines URLs to
be relative to the style sheet, but Navigator 4.x inter-
prets URLs relative to the document being styled. Thus,
absolute URLs are recommended over relative URLs.
Style Precedence
A single HTML document can import multiple external style
sheets, use an embedded style sheet, and specify inline
Specificity Calculations
ID selector 1,0,0
Style Precedence
}
The Cascade
The cascade order provides a set of rules for resolving con-
flicts between different style sheets. Styles with more
weight (those defined at a more specific level) take prece-
dence over styles with lower weight. The following steps
constitute the cascade:
Classification of Elements
in CSS, elements are grouped into three typ
Block-level dements
Elements such as paragraphs, headings, lists, tables,
divs, and Replaced elements, such as images and
body.
form inputs, can be block-level elements but usually
elements are displayed on
aren't. In general, block-level
Inline elements
Elements such as the anchor element (A), EM, SPAN, and
most replaced elements, such as images and form
inputs. Inline elements don't force a line break before or
after the element. They can be children of any other
block, inline, or list-style element.
List-item elements
Elements that in HTML include only the LI element.
These are specially defined to have presentation aspects
such as a marker (a bullet, letter, or number) and, if
within an ordered list, a sense of numerical order. Thus,
list-items within such a list can be automatically num-
bered, based on their context within the document.
Classification of Elements 11
various components of an element's displayed box. In addi-
tion, the following rules apply:
top margin
— top border —
top padding
S s
§«- width •
HI
II I
I
I
bottom padding
— bottom border —
bottom margin
Inline Formatting
Content area
The box defined by the font-size of each piece of text
(whether in an element or not)
Half-leading
The distance determined i>\ the value <>f line-height.
where the half-leading equals << font-size -
Line-heigl
2).
Inlinebox
The box defined by subtracting the hall leading from the
top and bottom of the content area; foi ,m\ giver p
of text, the height of the Inline box is always equal to
the value of line-height for that same text.
Line box
The actual box that is stacked below the previous line
box; this bounds the top of the highest inline- box and
the bottom of the lowest inline box in the line
|
line-height\of 60%
half-leading
^superscript^
text with and some! £>Hj text
Float Behavior
/ Supported
/ Not supported
P Partial support (some values are supported, souk- aren't)
:active
Inherited: Yes
doesn't say what they are, and no user agent is known to support
:active on any element other than a hyperlink.
: active 15
Examples:
:first-letter
Inherited: Yes
text-decoration
text-transform
text-shadow
line-height
vertical-align (if float is none)
float
clear
Any font properly
Examples:
:firsMine
Inherited: Yes
Applies styles to the first line oJ an element. The styles arc applied
even if the window is Is simply restyled to encom-
resized; the texl
pass only the element. This can be used to emulate
first line of the
common typographic effects such as larger text in the first line Of a
change of color. The range of properties that can be used with
: first-line is limited to:
• word-spacing
• letter-spacing
• text-decoration
• text-transform
• text-shadow
• vertical-align
• clear
• Any font property
Examples:
{important
Inherited: Yes
{important 17
Examples:
:link
Inherited: '
fes
Examples:
:visited
Inherited: Yes
background
Values:
|
background-attachment
|
background- posit ion
|
|
Inherited: No
Applies to: All elements
Mac X / P / - -
explicitly declared. Thus the following two rules have the same
appearance:
background: yellow;
background: yellow none top left repeat;
Hi {background-repeat: repeat-x;}
Hi, H2 {background: yellow url(headback.gif);}
In this case, the repeat value for both Hi and H2 elements is set to
the default of repeat, overriding the previously declared value of
repeat-x. Note that percentage values are allowed for the
background-position value.
Navigator 4.x is legendary- for its inability to correctly render back-
grounds. If there's no border around an element, the background
is visible only behind the text of the element, instead of
throughout the entire content-area and padding. Unfortunately, if a
border is added, there will be a transparent gap between the
background 19
content-area and the border itself. This isn't the padding, and
there's no way to get rid of the gap.
Examples:
background-attachment
Default: scroll
Inherited: No
Applies to: All elements
Win / / / X / / /
Mac / / - X / - - *
Examples:
background-color
Default: transparent
Inherited: No
Applies to: All elements
background has been repeated, and the rest <>f the background of
the element is transparent (either by default or when explicitly
declared). Scrolling the element offscreen and then bringing ku k it
Examples:
H4 {background-color: white;}
P {background-color: rgb(50%,50%,50%);}
PRE {background-color: background: #FFFF99;
background-image
Default: none
Inherited: No
Applies to: All elements
Examples:
background-image 21
background-position
Values:
[left center
1 right 1
]
Default: 0% 0%
Inherited: No
Applies to: Block elements and replaced elements
Cascading Style Sheets.- The Definitive Guide for more details. When
percentage or length values are used, the first is always the hori-
zontal position, and the second the vertical. It's possible to mix
length and percentage units, but keywords (e.g., top) can't be
mixed with either length or percentage units. If only one value is
given, it while the missing value is
sets the horizontal position,
assumed to be either center or 50%. Negative values are permitted.
A background image can be positioned outside the element's
content area. In this case, only the portion inside the content area
is displayed.
Examples:
background-repeat
Default: repeat
Inherited: No
ilv» Win repeats onl\ down and to the left Foi example ."peat-x
causes an image to tile from the origin image ' ( >
the right '
the left.
Examples:
border
Default: n/a
Inherited: No
Applies to: All elements
border 23
Examples:
border-bottom
Default: n/a
Inherited: No
Applies to: All elements
Examples:
border-bottom-width
Default: medium
Inherited: No
Applies to: All elements
Examples:
UL {border-bottom-width: 0.5in;}
A:active {border-bottom-width: 2px;}
border-color
Inherited: No
Applies to: All elements
Navigator 4.x and Opera 3.6 don't set colors on individual sides, as
in border-color: red blue green purple. IE4 and Win/IE5 cant
apply border colors to inline elements, since they don't apply
borders to inlines, but this isn't penalized here.
Examples:
Hi {border-color: purple;}
A: visited {border-color: maroon;}
border-left
Default: n/a
Inherited: No
Applies to: All elements
border-color 25
Support:
Defines the width, color, and style of the left border of an element.
The usual cawats about border- style apply.
Examples:
border-left-width
Default: medium
Inherited: No
Applies to: All elements
Sets the width of the left border of an element, which inherits the
element's background and may have a foreground of its own (see
border- style). Negative length values aren't permitted. The usual
caveats about border- style apply.
Examples:
P {border-left-width: 3em;}
PRE {border-left-width: 4px;}
border-right
Inherited: No
Applies to: All elements
Examples:
border-right-width
Default: medium
Inherited: No
Applies to: All elements
Sets the width of the right border of an element, which inherits the
element's background and may have a foreground of its own (see
border- style). Negative length values aren't permitted. The usual
caveats about border- style apply.
get really ugly when borders are applied to inline styles. IE4 and
Win/IE5 correctly handle borders on block-level elements but
ignore them for inlines.
Examples:
border-right-width 27
border-style
Values:
inset I outset
Default: none
Inherited: No
Applies to: All elements
Sets the style of the overall border of an element, using either the
color set by border- color or the foreground of the element itself if
no border- color has been defined. Note that setting the border-
style to none (its default value) results in no border at all. In this
case, any value of border-width is ignored, and the width of the
border set to zero. CSS1 doesn't require recognition of any values
besides none and solid. Any unrecognized value from the list of
values should be reinterpreted as solid.
Examples:
Hi {border-style: solid;}
IMG {border-style: inset;}
border-top
Default: n/a
Inherited: No
Applies to: All elements
Defines the width, color, and style of the top border of an element.
The usual caveats about border- style apply.
Examples:
Default: medium
Inherited: No
Applies to: All elements
Examples:
UL {border-top-width: 0.5in;}
Hi {border-top-width: lpx;}
border-width
Default: n/a
Inherited: No
Applies to: All elements
border-top-width 29
Support: IE4 IE5 IE55 NN4 NN6 0p3 0p4
Win P P / B / / /
Mac P / - B /
gel really ugly when borders are applied to inline styles. IE4 and
Win/I E5 correctly handle borders on block-level elements but
ignore them for inlines.
Examples:
Hi {border-width: 2ex;}
IMG {border-width: 5px;}
clear
Default: none
Inherited: No
Applies to: All elements
Win P P / P / B /
I
Mac / / - P / - - |
Examples:
Hi {clear: both;}
H3 {clear: right;}
color
Values: color
Inherited: Yes
Sets the foreground color of a given element Poi texl this sets the
text color; for bitmap images su< h as < ,n and M'< I n has no effei I
Examples:
display
Default: block
Inherited: No
Applies to: All elements
Win P P P P / P /
|
Mac P / P / - " I
color 31
such hierarchy, display is indispensable. In CSS2, the range of
values for display is expanded but not well supported.
( )pera 3.6 almost gets inline right but seems to honor the occa-
sional carriage return as though it were a <BR> element, instead of
plain whitespace.
Examples:
float
Default: none
Inherited: No
Applies to: All elements
Examples:
font
Values:
[font-style font-variant
I I I I
font -weight
[/ line-height J? font- family
Inherited: Yes
A shorthand property for the other font properties. Any values may
be omitted except for font-size and font -family, which are
always required for a valid font declaration and must appear in
that order. Note the incorrect examples shown.
Examples:
font-size */
P. wrong {font: I2pt Times, serif bold;} /* font-weight
font-family
Values:
[[family-name generic-family I
],]* [family-name I
generic-family ]
font 33
Inherited: Yes
Examples:
font-size
Values:
Default: medium
Inherited: Yes
Sets the size of the font. This can be defined as an absolute size, a
Examples:
H2 {font-size: 200%;}
CODE {font-size: 0.9em;}
P. caption {font-size: 9px;}
font-style
Default: normal
Inherited: Yes
Sets the font to use either italic, oblique, or normal text. Italic text
font-style 35
Examples:
EM {font-style: oblique;}
I {font-style: italic;}
font-variant
Default: normal
Inherited: Yes
Win Q Q Q X / / /
Mac Q / - X / - -
This currently has two values: small-caps and normal. The small-
caps variant can either be applied as a face of the selected font or
computed by the user agent. Under the rules of CSS, user agents
can claim support for small -caps by simply uppercasing all the
letters. Since this isn't typically what you'd expect, user agents that
Examples:
H3 {font-variant: small-caps;}
P {font-variant: normal;}
font-weight
Values:
Default normal
Inherited: Yes
font lias only two weights—normal and bold the number* 100
through 500 arc normal, and 6oo through 900 are bold.
Examples:
B {font-weight: 700;}
STRONG {font-weight: bold;}
.delicate {font-weight; lighter;}
height
Values: length |
auto
Default: auto
Inherited: No
Applies to: Block level elements and replaced elements
Examples:
letter-spacing
Default: normal
Inherited: Yes
height 37
Sets the amount of whitespace between letters. A letter is defined
as any displayed character, including numbers, symbols, and other
font glyphs. Length values can define a modifier to the usual
spacing, not the entire space itself; thus, normal is synonymous
with (zero). Negative values are permitted and cause letters to
kern (bunch closer together).
Examples:
line-height
Values: normal |
number \
length |
percentage
Default: normal
Inherited: Yes
P {line-height: 1.5em;}
H2 {line-height: 200%;}
UL {line-height: 1.2;}
PRE {line-height: 0.75em;}
list-style
Values:
list-style-type |
|
list-style-position \ \
list-style-image
Default: n/a
Inherited: Yes
Support:
WlnP//P///
Mac
IE4
P
IE5
/
IE55
-
NN4
P
NN6
/
0p3
-
0p4
Examples:
list-style-image
Values: url |
none
Default: none
Inherited: Yes
list-style 39
Declares an image that is used as the bullet in an unordered or
ordered list. This style applies to elements with a display value of
Examples:
UL {list-style-image: url(bullet3.gif);}
UL LI {list-style-image:
url(http://my.web.site/pix/sun.png);}
list-style-position
Default: outside
Inherited: Yes
Win / / / X / / /
Mac / / - X / - - !
Examples:
LI {list-style-position: outside;}
OL LI {list-style-position: inside;}
list-style-type
Values:
disc circle|
square decimal |
lower-roman
| |
|
Inherited: Yes
Examples:
UL {list-style-type: square;}
OL {list-style-type: lower-roman;}
margin
Values: [ length \
percentage |
auto ]{l,4}
Default: n/a
Inherited: No
Applies to: All elements
i
Mac P / - B / - -
margin 41
elements to overwrite other parts of a page or to appear wider
than their parent elements. Percentage values of margin refer to
the width of the closest block-level ancestor.
Opera 4's problems with correctly applying right and left margins
to inline elements seem to get worse if you use the margin short-
hand property.
Examples:
Hi {margin: 2ex;}
P {margin: auto;}
IMG {margin: 10px;}
margin-bottom
Values: length |
percentage |
auto
Default:
Inherited: No
Applies to: All elements
UL {margin-bottom: 0.5in;}
Hi {margin-bottom: 2%;}
margin-left
Default:
Inherited: No
Applies to: All dements
Support: IE4 IE5 IE55 NN4 NN6 0p3 0p4
P P / B / /
P / - B / -
edge of the element to push outside the left edge of the parent
element(s). Percentage values of margin -left refer to width of the
closest block-level ancestor.
Examples:
P {margin-left: 5%;}
PRE {margin-left: 3em;}
margin-right
Default:
Inherited: No
Applies to: All elements
margin-left 43
margin of an element. Negative values are
Sets the size of the right
permitted, but caution recommended, as they can cause the right
is
edge of the element to push outside the right edge of the parent
element(s). Percentage values of margin -right refer to width of
the closest block-level ancestor.
Examples:
margin-top
Default:
Inherited: No
Applies to: All elements
Sets the size of the top margin of an element. Negative values are
permitted, but caution is recommended, as they can pull the
element up into preceding elements, possibly overwriting some or
all of the preceding elements. Top margins on inline elements have
Examples:
UL {margin-top: 0.5in;}
H3 {margin-top: l.5em;}
Default: n/a
Inherited: No
Applies to: All elements
Examples:
Hi {padding: 2ex;}
IMG {padding: 10px;}
padding-bottom
Default:
Inherited: No
padding 45
Applies to: All elements
Win P P / B / /
Mac P / B / - 1
Examples:
UL {padding-bottom: 0.5in;}
HI {padding-bottom: 2%;}
padding-left
Default:
Inherited: No
Applies to: All elements
Sets the size of the left padding of an element. This padding uses
the element's background, if one has been set. Negative values
Examples:
P {padding-left: 5%;}
PRE {padding-left: 3em;}
Default:
Inherited: No
Applies to: All el< merits
Examples:
padding-top
Default:
Inherited: No
Applies to: Ail elements
Sets the size of the top padding of an element. This padding uses
the element's background, if one has been set. Negative values
padding-right 47
Examples:
UL {padding-top: 0.5in;}
H3 {padding-top: l.5em;}
text-align
Inherited: Yes
Examples:
P {text-align: justify;}
H4 {text-align: center;}
text-decoration
Values:
none I
[ underline I I overline I I line-through I I blink ]
Default: none
Inherited: No
Applies to: All elements
sets certain effects on the text, such as underline and blink. Usef
agents aren't required to support blink. These decorations span
Examples:
U {text-decoration: underline;}
.old {text-decoration: line-through;}
U.old {text-decoration: line-through underline;}
text-indent
Default:
Inherited: Yes
i Win P P / B / / B
1
Mac P / - B / - ~ 1
text-indent 49
Examples:
P {text-indent: 5em;}
H2 {text-indent: -25px;}
text-transform
Default: none
Inherited: Yes
//-//-
IE4 IE55 6p3 0p4
Win / / / / / P /
Mac -
Examples:
Hi {text-transform: uppercase;}
.title {text-transform: capitalize;}
vertical-align
Values:
baseline sub super
I top I I I text-top I middle I bottom I
text-bottom percentage I
Default: baseline
Inherited
Examples:
white-space
Default: normal
Inherited: Yes
Examples:
TD {white-space: nowrap;}
TT {white-space: pre;}
width
Default: auto
Inherited: No
Applies to: Block elements and replaced elements
white-space 51
Support: 1
Sets the width ofan element. This is most often applied to images,
but can be used on any block-level or replaced element.
Percentage values refer to the parent element's width. Negative
values aren't permitted.
Examples:
word-spacing
Default: normal
Inherited: Yes
/ Supported
X Not supported
This chart and its notes are current as of January 2001. For
the latest information, visit http://style.webreview.com/.
Containment in HTML P / B / /
LINK / / B / /
<STYLE>...</STYLE> / / / / /
©import / / / / /
<x S7YLE»"dec;"> B / / X /
Grouping / / / / /
x, y, z{dec;} / / / / /
Inheritance B / B / /
(inherited values) B / B / /
Class selector / / B / /
.class / / B / /
ID selector B / B B /
#ID B / B B /
Contextual selectors B / P / /
xyzjdec;} B / P / /
Comments / / / / /
/* comment */ / / / / /
Notes
7.7 Containment in HTML ©import
WinIE4+ imports files even when the @import statement is at
the end of the document style sheet. This is technically in viola-
tion of the CSS1 specification, although obviously not a major
failing; thus the Q rating.
/ .-> inheritance
Navigator Vs inheritance is unstable at best, and fatally flawed
at worst It would take too long to list all occurrences, but par-
ticularty troublesome areas include tables and lists.
i .5 /D selector
WinIE4/5 allows ID names to begin with digits; this isn't per-
mitted under CSS1. All browsers apply the style for a given ID
to more than one instance of that ID in an HTML document,
which isn't permitted. This is properly an error-checking prob-
lem and not a failing of the CSS implementations, but I feel it's
significant enough to warrant the ratings shown.
anchor P / B / /
:link / / B / /
:active X / X / /
:visited X / B / /
first-line X / B X /
:first-line X / B X /
first-letter X / B X /
: first- letter X / B X /
Notes
2 3 first-line
IE3 incorrectly applies : first -line styles to the entire element.
2.4 first-letter
IE3 incorrectly applies :first -letter styles to the entire
element.
/ / X / / / / /
B / X / / / X X
B / X / / / / /
X / X X X / / /
X / X X X / / /
X / X X X / / /
X / X X X / / /
important X / / / /
(important / / / / /
Cascading Order B / P / /
Weight sorting B / / / /
Origin sorting B / B / /
Specificity sorting B / B / /
Order sorting B / / / /
Notes
32 Cascading Order
There are simply far too many instances of NN4 problems to list
The Cascade 59
Font Properties
Macintosh
font-family / / P / /
<family-name> / / P / /
<generic-family> / / P / /
serif / / / / /
sans-serif / / X / /
cursive / / X / /
fantasy / / X / /
monospace / / / / /
font-style P / p / /
normal / / X / /
italic / / / / /
oblique X / X / /
font-va riant X / X Q /
normal X / X / /
small-caps X / X Q /
Font Properties 61
Macintosh
font-weight P / P / /
normal / / X / /
bold / / / / /
bolder X / X / /
lighter X / X / /
100 - 900 / / X / /
font-size / / p Q /
<absolute-size> / / B Q /
xx-small - xx-large / / B Q /
<relative-size> / / X / /
larger / / X / /
smaller / / X / /
<length> / / B / /
<percentage> / / P / /
font P / P Q /
<font-family> / / P / /
<font-style> / / P / /
<font-variant> X / X Q /
<font-weight> / / X / /
<font-size> / / B / /
<line-height> B / B / /
Notes
5.2.6 font-size xx-small - xx-large
Winllw 5 55 and MacIE-4 5 all set the default font-size value
to small instead of medium. (The exception is IE5 Mac when its
Font Properties 63
Color and Background Properties
Macintosh
color / / / / /
<color> / / / / /
background-color B / X / /
<color> B / X / /
transparent B / X / /
background-image / / X / /
<url> / / X / /
none / / X / /
background-repeat B / X / /
repeat / / X / /
repeat-x P / X / /
repeat-y P / X / /
no-repeat / / X / /
Notes
53-2 background-color <color>
Nav4 doesn't apply the background color to the entire content
box and padding, just to the text in the element. This can be
worked around by declaring a zero-width border.
53-2 background-color transparent
Nav4 insists on applying this value to the parent of an element,
not the element itself. This can lead to "holes" in the parent ele-
ment's background.
/ / X / / / / /
/ / X / / / / /
/ / X / / / / /
P / X p / / / /
/ / X B / / / /
P / X B / / / /
P / X B / / / /
/ / X / / / / /
background-attachment X / X / /
scroll X / X / /
fixed X / X / /
background-position X / X / /
<percentage> X / X / /
<length> X / X / /
top X / X / /
center X / X / /
bottom X / X / /
left X / X / /
right X / X / /
background p / p / /
<background-color> p / p / /
<background-image> p / / / /
<background-repeat> p / B / /
<background-attachment> X / / / /
<background-position> X / P / /
B / p / / / / /
p / / / / / / /
p / B B / / / /
X / X / / / X /
X / X / / / / /
word-spacing X / X / /
normal X / X / /
<length> X / X / /
letter-spacing X / X / /
normal X / X / /
<length> X / X / /
text-decoration B B B B P
none Q / / Q /
underline Q / B Q /
overline X / X / /
line-through / / / / /
blink / / X X X
vertical-align X / X p /
baseline X / X / /
sub X / X / /
super X / X / /
top X / X / /
text-top X / X / /
Notes
5.4.3 text-decoration none
According to the specification, if an element is decorated, but
one of its children isn't, the parent's effect is still visible on the
child; in a certain sense, it "shines through." Thus, if a para-
graph is underlined, but a STRONG element within it is set to
Q / X / / / / /
Q / B / / / / /
X / X / / / / /
/ / / / / / / /
/ / X X X X X /
X / X p p p P /
X / X / / / / /
X / X / / / / /
X / X / / / / /
X / X X X / B /
X / X X X / X /
Text Properties 69
Macintosh
middle X / X / /
bottom X / X B /
text-bottom X / X B /
<percentage> X / X B /
text-transform / / X / /
capitalize / / X / /
uppercase / / X / /
lowercase / / X / /
none / / X / /
text-align P / p P /
left / / / / /
right / / / / /
center / / / / /
justify B / X X /
text-indent / / / / /
<length> / / / / /
<percentage> / / / / /
line-height P / p / /
normal / / / / /
<number> P / B / /
<length> B / B / /
<percentage> P / B / /
shouldn't do.
5.4.S line-height
Opera 3-6 applies background colors to the space between
lines, as opposed to just the text itself, when the background is
set for an inline element within the text. (See the CSS1 Test
Suite for more details.)
Text Properties 71
Box Properties
Macintosh
margin-top P / B P /
<length> P / B P /
<percentage> P / B P /
auto P / B P /
margin-right B B P P /
<length> B / / P /
<percentage> B / / P /
auto X / X P /
margin -bottom X / X P /
<length> X / X P /
<percentage> X / X P /
auto X / X P /
margin-left B / p P /
<length> / / / P /
<percentage> B / / P /
auto B / X P /
Notes
5. 5.01 margin-top
All margin properties seem to be problematic, or else complete-
ly unsupported, on inline elements; see margin for details.
5. 5.02 margin-right
All margin properties seem to be problematic, or else complete-
ly unsupported, on inline elements; see margin for details.
noticeable.
B / / P P / / /
B / X P P / / /
X / X X X / / /
X / / p P / / /
X / X p P / / /
X / X p P / / /
X / X p P / / /
B / p p P / / B
B / / p P / / /
B / / p P / / /
X / X X X / / /
5.5.03 margin-bottom
All margin properties seem to be problematic, or else complete-
ly unsupported, on inline elements; see margin for details.
5.5.04 margin-left
All margin properties seem to be problematic, or else complete-
ly unsupported, on inline elements; see margin for details.
Box Properties 73
Macintosh
Property or Value N4 N6 IE3 IE4 IE5
margin B B B P /
<length> B / B P /
<percentage> B / B P /
auto X / B P /
padding-top B / X P /
<length> B / X P /
<percentage> B / X P /
padding-right B / X P /
<length> B / X P /
<percentage> B / X P /
padding-bottom B / X P /
<length> B / X P /
<percentage> B / X P /
Notes
5. 5.05 margin
margin is fairly well supported on block-level elements in most
browsers, with the notable exception of NN4.X. margin on
inline elements is fully supported in IE5/Mac, IE55 Win. NN6,
and Opera 4/5. margin should never be used on inline ele-
ments in NN4.X, which has severe and page-mangling bugs.
Opera 4's problems with correctly applying right and left mar-
gins to inline elements seems to get worse with margin.
B/B
B
B//P P///
B~~ B~~ P~~ ~~P
P P
7
/
7
/
B~~
/
X
B
P/// /
/
/
X
P
p p Q / /
B / X p p / / /
B / X p p / / /
B / X p p Q / /
B / X p p / / /
B / X p p / / /
B / X p p / / /
B / X p p / / /
B / X p p / / /
5.5. 06 padding-top
All padding properties seem to be problematic, or else com-
pletely unsupported, on inline elements; see padding for
details.
5.5. 7 padding-right
All padding properties seem to be problematic, or else com-
pletely unsupported, on inline elements; see padding for
details.
55. 08 padding-bottom
All padding properties seem to be problematic, or else com-
pletely unsupported, on inline elements; see padding for
details.
Box Properties 75
Macintosh
Property or Value N4 N6 IE3 IE4 IE5
padding-left B / X P /
<length> B / X P /
<percentage> B / X P /
padding B / X P /
<length> B / X P /
<percentage> B / X P /
border-top-width B / X P /
thin / / X P /
medium / / X P /
thick / / X P /
<length> / / X P /
border-right-width B / X P /
thin / / X P /
medium / / X P /
thick / / X P /
<length> / / X P /
Notes
5. 5 .09 padding-left
All padding properties seem to be problematic, or else com-
pletely unsupported, on inline elements; see padding for
details.
5.5. 10 padding
padding is fairly well supported on block-level elements in
5.5.11 border-top-width
Navigator creates visible borders even when no border- style
is set and doesn't set borders on all when
sides a style is set.
Things get really ugly when borders are applied to inline styles.
5.5.12 border-right-width
Navigator 4.x creates visible borders even when no border-
style is set and doesn't set borders on all sides when a style is
set. Things get really ugly when borders are applied to inline
IE4 and IE5 correctly handle borders on block-level
styles. ele-
Box Properties 77
Macintosh
border-bottom-width B / X P /
thin B / X P /
medium B / X P /
thick B / X P /
<length> B / X P /
border-left-width B / X P /
thin / / X P /
medium / / X P /
thick / / X P /
<length> / / X P /
border-width B / X P /
thin / / X P /
medium / / X P /
thick / / X P /
<length> / / X P /
border-color P / X / /
<color> P / X / /
Notes
5.5.13 border-bottom-width
Navigator 4.x creates visible borders even when no border-
style is set and doesn't set borders on all sideswhen a style is
set. Things get really ugly when borders are applied to inline
styles. IE4 and IE5/Win correctly handle borders on block-level
elements but ignore them for inlines.
5.5. 14 border-left-widtb
Navigator creates visible borders even when no border- style
is set and doesn't set borders on all sides when a style is set.
Things get really ugly when borders are applied to inline styles.
55. 75 border-width
Navigator creates visible borders even when no border- style
is set and doesn't set borders on all when
sides a style is set.
Things get really ugly when borders are applied to inline styles.
Box Properties 79
Macintosh
Property or Value N4 N6 IE3 IE4 IE5
border-style P / X / /
none / / X / /
dotted X / X / /
dashed X / X / /
solid / / X / /
double / / X / /
groove / / X / /
ridge / / X / /
inset / / X / /
outset / / X / /
border-top X / X p /
<border-top-width> X / X p /
<border-style> X / X p /
<color> X / X p /
border-right X / X p /
<border-right-width> X / X p /
<border-style> X / X p /
<color> X / X p /
border-bottom X / X p /
<border-bottom-width> X / X p /
<border-style> X / X p /
<color> X / X p /
Notes
5.5.18 border-top
Opera3 doesn't apply border styles to table elements, which is
the reason for the P rating. IE4 and IE5 don't apply borders to
inline elements.
5.5.19 border-right
Opera3 doesn't apply border which
styles to table elements, is
the reason for the P rating. IE4 and IE5 don't apply borders to
inline elements.
Box Properties 81
Macintosh
border-left X / X P /
<border-left-width> X / X P /
<border-style> X / X P /
<color> X / X P /
border P / X P /
<border-width> B / X P /
<border-style> P / X P /
<color> / / X P /
width P / X / /
<length> P / X / /
<percentage> P / X / /
auto P / X / /
height X / X / /
<length> X / X / /
auto X / X / /
Notes
5. 5.20 border-bottom
Opera3 doesn't apply border styles to table elements, which is
the reason for the P rating. IE4 and IE5 Win don't apply bor-
ders to inline elements, which is the reason for those P ratings.
5.5.21 border-left
Opera3 doesn't apply border styles to table elements, which is
the reason for the P rating. IE4 and IE5 don't apply borders to
inline elements.
5. 522 border
Opera3 doesn't apply border styles to table elements, which is
the reason for the P rating. IE4 and Win/IE5 don't apply bor-
ders to inline elements, which is the reason for those P ratings.
5.5.23 ww/tf?
Navigator 4.x applies width in an inconsistent fashion but
appears to honor on most simple text elements and images.
it
Box Properties 83
Macintosh
Property or Value N4 N6 IE3 IE4 IE5
float P / X B Q
left B / X / /
right B / X / /
none / / X / /
clear P / X / /
none / / / / /
left B / X / /
right B / X / /
both / / X / /
Notes
5.5.25float
float is one of the most complicated and hardest-to-imple-
their act to a large degree, leaving WinIE4 and Nav4 the major
transgressors in this respect. Authors should use float with
some care and thoroughly test any pages employing it.
5.5.26 cfetfr
Like float, clear isn't a simple thing to support. There is typi-
Box Properties 85
Classification Properties
Macintosh
Property or Value N4 N6 IE3 IE4 IE5
display P / X P /
block B / X P /
inline X / X X /
list- item P / X p /
none / / X / /
white-space P / X X /
normal / / X X /
pre / / X X /
nowrap X / X X /
list-style-type P / X / /
disc / / X / /
circle / / X / /
square / / X / /
decimal / / X / /
lower-roman / / X / /
upper-roman / / X / /
lower-alpha / / X / /
upper-alpha / / X / /
none B / X / /
Notes
5.6.1 display inline
Opera 3.6 almost gets inline right, but seems to honor the
occasional carriage return as though it were a <BR> element,
instead of plain whitespace.
Classification Properties 87
Macintosh
list-style-image X / X / /
<url> X / X / /
none X / X / /
list-style-position X / X / /
inside X / X Q /
outside X / X / /
list-style P / X P /
<keyword> P / X / /
<position> X / X Q /
<url> X / X / /
Classification Properties
Units
Macintosh
Length Units / / B / /
em / / / / /
ex Q / Q Q /
px / / / / /
in / / / / /
cm / / / / /
mm / / / / /
Pt / / / / /
pc / / / / /
Percentage Units / / / / /
<percentage> / / / / /
Color Units P / P / /
#000 / / B / /
#000000 / / B / /
(RRR,GGG,BBB) / / / / /
(R%,G%,B%) / / X / /
<keyword> B / / / /
URLs B / B / /
<url> B / B / /
Notes
6 / Length Units ex
All supporting browsers appear to calculate ex as one-half em.
This is arguably a reasonable approximation, but it's technical-
ly incorrect.
Units 91
Web Design
O REILLY'
CSS Pocket Reference
Cascading Style Sheets, or CSS, is the W3C-
approvecl method for controlling the visual
presentation of web pages.
US $9.95
ISBN 0-596-00120-7 CAN $14.95
90000
780596"001209 36920"00120'