CSS: The Definitive Guide, 3rd Edition (76 page)

Read CSS: The Definitive Guide, 3rd Edition Online

Authors: Eric A. Meyer

Tags: #COMPUTERS / Web / Page Design

BOOK: CSS: The Definitive Guide, 3rd Edition
12.33Mb size Format: txt, pdf, ePub
Appendix C. Sample HTML 4 Style Sheet

The following style sheet is adapted from Appendix D of the CSS2.1 specification. There
are two important things to note. The first is that while CSS2.1 says that "developers are
encouraged to use [this] as a default style sheet in their implementations," this isn't
always possible. For example, there is a rule that states:

ol, ul, dir, menu, dd
{margin-left: 40px;}

This describes the legacy indenting of lists to a distance of 40 pixels, and it uses a
left margin to do it. However, some browsers have used a 40-pixel left padding instead of a
margin, believing this to be a better solution. (See
Chapter
12
for details.) Therefore,
you cannot rely on this as the exact
default style sheet for any given user agent
. It is provided more for
illustrative purposes and as a learning tool.

The second thing to note is that not all HTML elements are fully described in this style
sheet because CSS is not yet detailed enough to completely and accurately describe them.
The classic examples are form elements, such as submit buttons, which are replaced elements
but have their own special formatting needs. Submit buttons are replaced elements, and thus
the bottom edge of their box should align with the baseline. Authors, however, are likely
to expect the text inside the button to align with the baseline of other text in the same
line. This is a reasonable expectation, but CSS does not (as of this writing) have the
ability to describe such behavior; therefore, all that is said about such elements is the
following rule:

button, textarea, input, object, select, img {
display:inline-block;}

The rest of the formatting of such elements is left to the user agent.

With these caveats in mind, here is the style sheet (with some slight reformatting)
found in the CSS2 specification. Any changes other than reformatting are noted in comments.

address, blockquote, body, dd, div, dl, dt, fieldset, form,
frame, frameset, h1, h2, h3, h4, h5, h6, noframes,
ol, p, ul, center, dir, hr, menu, pre {
display: block;}
li {display: list-item;}
head {display: none;}
table {display: table;}
tr {display: table-row;}
thead {display: table-header-group;}
tbody {display: table-row-group;}
tfoot {display: table-footer-group;}
col {display: table-column;}
colgroup {display: table-column-group;}
td, th {display: table-cell;}
caption {display: table-caption;}
th {font-weight: bolder; text-align: center;}
caption {text-align: center;}
body {padding: 8px; line-height: 1.12em;}
h1 {font-size: 2em; margin: .67em 0;}
h2 {font-size: 1.5em; margin: .75em 0;}
h3 {font-size: 1.17em; margin: .83em 0;}
h4, p, blockquote, ul, fieldset, form, ol, dl, dir, menu {
margin: 1.12em 0;}
h5 {font-size: .83em; margin: 1.5em 0;}
h6 {font-size: .75em; margin: 1.67em 0;}
h1, h2, h3, h4, h5, h6, b, strong {
font-weight: bolder;}
blockquote {margin-left: 40px; margin-right: 40px;}
i, cite, em, var, address {
font-style: italic;}
pre, tt, code, kbd, samp {
font-family: monospace;}
pre {white-space: pre;}
button, textarea, input, object, select, img {
display:inline-block;}
big {font-size: 1.17em;}
small, sub, sup {font-size: .83em;}
sub {vertical-align: sub;}
sup {vertical-align: super;}
s, strike, del {text-decoration: line-through;}
hr {border: 1px inset;}
ol, ul, dir, menu, dd {
margin-left: 40px;}
ol {list-style-type: decimal;}
ol ul, ul ol, ul ul, ol ol {
margin-top: 0; margin-bottom: 0;}
u, ins {text-decoration: underline;}
br:before {content: "\A";}
center {text-align: center;}
abbr, acronym {font-variant: small-caps; letter-spacing: 0.1em;}
:link,:visited {text-decoration: underline;}
:focus {outline: thin dotted invert;}
/* Begin bidirectionality settings (do not change) */
BDO[DIR="ltr"] {direction: ltr; unicode-bidi: bidi-override;}
BDO[DIR="rtl"] {direction: rtl; unicode-bidi: bidi-override;}
*[DIR="ltr"] {direction: ltr; unicode-bidi: embed;}
*[DIR="rtl"] {direction: rtl; unicode-bidi: embed;}
@media print {
h1 {page-break-before: always;}
h1, h2, h3, h4, h5, h6 {
page-break-after: avoid;}
ul, ol, dl {page-break-before: avoid;}
}
@media aural { /* changed from 'speech' which was not defined in CSS2 */
h1, h2, h3, h4, h5, h6 {
voice-family: paul, male; stress: 20; richness: 90;}
h1 {pitch: x-low; pitch-range: 90;}
h2 {pitch: x-low; pitch-range: 80;}
h3 {pitch: low; pitch-range: 70;}
h4 {pitch: medium; pitch-range: 60;}
h5 {pitch: medium; pitch-range: 50;}
h6 {pitch: medium; pitch-range: 40;}
li, dt, dd {pitch: medium; richness: 60;}
dt {stress: 80;}
pre, code, tt {pitch: medium; pitch-range: 0; stress: 0; richness: 80;}
em {pitch: medium; pitch-range: 60; stress: 60; richness: 50;}
strong {pitch: medium; pitch-range: 60; stress: 90; richness: 90;}
dfn {pitch: high; pitch-range: 60; stress: 60;}
s, strike {richness: 0;}
i {pitch: medium; pitch-range: 60; stress: 60; richness: 50;}
b {pitch: medium; pitch-range: 60; stress: 90; richness: 90;}
u {richness: 0;}
a:link {voice-family: harry, male;}
a:visited {voice-family: betty, female;}
a:active {voice-family: betty, female; pitch-range: 80; pitch: x-high;}
}
Index
A note on the digital index

A link in an index entry is displayed as the section title in which that entry appears. Because some sections have multiple index markers, it is not unusual for an entry to have several links to the same section. Clicking on any link will take you directly to the place in the text in which the marker appears.

A
a
element,
Pseudo-Classes and Pseudo-Elements
absolute length units,
Absolute Length Units
absolute positioning,
The containing
block
,
The containing
block
,
Absolute Positioning
,
Absolute Positioning
,
Containing blocks and
absolutely positioned elements
,
Placement and sizing of absolutely positioned elements
,
Placing and sizing
nonreplaced elements
,
Placing and sizing
replaced elements
,
Placement on the
z-axis
,
Placement on the
z-axis
containing
blocks and,
The containing
block
,
Absolute Positioning
height and width
affecting,
Placement and sizing of absolutely positioned elements
nonreplaced
elements,
Placing and sizing
nonreplaced elements
on
z-axis,
Placement on the
z-axis
replaced
elements,
Placing and sizing
replaced elements
scrolling
and,
Containing blocks and
absolutely positioned elements
stacking
context and order for,
Placement on the
z-axis
absolute
URL,
URLs
adjacent-sibling combinator,
Selecting Adjacent Sibling Elements
adjacent-sibling selectors,
Child Selector
align
attribute, img element,
Floating
alignment,
Horizontal Alignment
,
Vertical Alignment
,
Baseline
alignment
,
Superscripting and
subscripting
,
Bottom
feeding
,
Bottom
feeding
,
In the
middle
,
In the
middle
,
Spacing and Alignment
,
Spacing and Alignment
,
Alignment
justified,
Horizontal Alignment
,
Spacing and Alignment
of
baseline,
In the
middle
of cell
content,
Alignment
of middle of
element,
In the
middle
spacing and,
Spacing and Alignment
superscripting and
subscripting,
Superscripting and
subscripting
to baseline,
Baseline
alignment
to bottom of line
box,
Bottom
feeding
to bottom of
text,
Bottom
feeding
vertical,
Vertical Alignment
alink attribute, body element,
Dynamic
pseudo-classes
active
pseudo-class and,
Dynamic
pseudo-classes
alt
attribute, attribute selectors used with,
Selection Based on Exact Attribute Value
alternate style sheets,
Alternate style
sheets
alternate stylesheet attribute,
Alternate style
sheets
ancestors of elements,
Understanding the Parent-Child Relationship
<> (angle brackets) in property
syntax,
Property Conventions
angle
brackets (<>) in property syntax,
Property Conventions
angle values,
inherit
animated
cursors,
Graphic cursors
aspect
value of font,
Stretching and Adjusting Fonts
asterisk (*),
Property Conventions
,
The universal
selector
,
Class Selectors
as universal
selector,
The universal
selector
,
Class Selectors
in property
syntax,
Property Conventions
attribute
selectors,
Attribute Selectors
,
Attribute Selectors
,
Specificity
,
ID Selector
,
Ending Substring Attribute Value Selector
simple attribute
selectors,
Attribute Selectors
specificity of,
Specificity
attribute values, as generated content,
Inserting attribute
values
audio rendering of content,
Pauses, cues, and
generated content
aural media type,
Attributes
,
Speaking
aural styles,
inherit
,
Aural Styles
,
Speech
rate
,
Volume
,
Giving Voice
,
Pauses and Cues
,
Cues
,
Pauses, cues, and
generated content
,
Positioning Sounds
,
page
,
cue-after
,
pause
,
pitch-range
,
speak
,
speak-punctuation
,
voice-family
background sounds
for,
Pauses, cues, and
generated content
cues in
speech,
Cues
,
cue-after
pauses in speech,
Pauses and Cues
,
pause
positioning sounds for,
Positioning Sounds
,
page
specifying content to be
spoken,
speak
speech rate
for,
Speech
rate
,
speak-punctuation
units used
with,
inherit
voice used for,
Giving Voice
,
pitch-range
,
voice-family
volume for,
Volume
author as
origin,
The Cascade
azimuth property,
Combining azimuth with elevation
B
background,
Basic Boxes
,
Margins Versus Padding
,
Borders
,
Borders and Backgrounds
,
Padding
,
Replacing Attributes
,
Inheriting Color
,
Backgrounds
,
Background Color
,
Good background
practices
,
Applied Behavior
,
Anonymous Table Objects
,
Handling empty
cells
,
background-color
colors
for,
Replacing Attributes
,
Background Color
,
background-color
design issues
regarding,
Good background
practices
extending into
padding,
Margins Versus Padding
,
Padding
,
Inheriting Color
extending to
borders,
Borders
,
Borders and Backgrounds
floated elements
and,
Applied Behavior
for columns and column
groups,
Anonymous Table Objects
for empty table
cells,
Handling empty
cells
of content
area,
Basic Boxes
background attribute, body element,
Special
effects
background
images,
Special
effects
,
Background Images
,
Background Images
,
Why backgrounds aren't inherited
,
Repeats with Direction
,
Background Positioning
,
Background Positioning
,
Length values
,
Getting Attached
,
Interesting
effects
,
Bringing It All Together
attaching to viewing
area,
Getting Attached
inheritance
and,
Why backgrounds aren't inherited
origin
image,
Background Positioning
positioning,
Background Positioning
special effects
with,
Interesting
effects
tiling,
Special
effects
,
Background Images
,
Repeats with Direction
,
Length values
background sounds,
play-during
background-color
property,
Special
effects
,
Good background
practices
combining with background-image
property,
Good background
practices
background-image property,
Using an
image
,
Good background
practices
combining with background-color
property,
Good background
practices
background-position property,
Keywords
,
Percentage values
,
Percentage values
,
Length values
,
Length values
default values for,
Percentage values
keyword values
for,
Keywords
length values for,
Length values
negative values for,
Length values
percentage values
for,
Percentage values
background-repeat property,
Repeats with Direction
,
background-repeat
backslash (\) escaping
linefeeds,
Inserting attribute
values
backward accessibility with older browsers,
Actual Style Rules
ball spinning, cursor,
Providing
help
baselines,
Baseline
alignment
,
In the
middle
,
Replaced elements and the
baseline
aligning elements
using,
Baseline
alignment
,
In the
middle
replaced elements
and,
Replaced elements and the
baseline
bidirectional text,
unicode-bidi
bleeding outside page box,
Projection Styles
block boxes,
Block-level
elements
,
Run-in Elements
,
Floating: The Details
,
Floats, Content, and Overlapping
,
The containing
block
,
Table Display Values
,
Captions
,
Lists
,
List Layout
,
Page-breaking
behavior
for floated elements,
Floating: The Details
for list items,
Lists
,
List Layout
for positioned
elements,
The containing
block
for table captions,
Captions
for tables,
Table Display Values
forcing with display
property,
Block-level
elements
,
Run-in Elements
overlapping floated
elements,
Floats, Content, and Overlapping
page breaks
between,
Page-breaking
behavior
block,
containing,
The Containing Block
block-level elements,
Elements
,
Block-level
elements
,
A Quick Refresher
,
Block-Level Elements
,
Block-Level Elements
,
Inline-Block Elements
boundaries
of,
Block-Level Elements
horizontal formatting
of,
Block-Level Elements
blur
radius for text shadow,
Text Shadows
body element,
Link
pseudo-classes
,
Dynamic
pseudo-classes
,
Inheritance
,
Special
effects
,
Containing blocks and
absolutely positioned elements
alink attribute,
Dynamic
pseudo-classes
as containing
block for positioned elements,
Containing blocks and
absolutely positioned elements
background
attribute,
Special
effects
inheritance of background
styles,
Inheritance
link and vlink
attributes,
Link
pseudo-classes
bold
text used in this book,
Conventions Used in This Book
border
property,
Inheritance
,
Global Borders
border-bottom property,
Vertical Formatting
border-bottom-style property,
border-bottom-style
border-collapse property,
Table Cell Borders
,
word-spacing
border-color property,
Border Colors
,
Affecting Borders
border-left property,
Horizontal
properties
,
border-left
border-left-style property,
Single-side
styles
border-left-width property,
border-left-width
border-right property,
Horizontal
properties
border-right-style property,
border-right-style
border-spacing property,
Border
spacing
,
border-spacing
border-style property,
Vertical
properties
border-top-style
property,
Single-side
styles
borders,
Basic Boxes
,
Basic Boxes
,
Basic Boxes
,
Adding box
properties
,
Adding box
properties
,
Borders
,
Borders
,
Borders
,
Borders
,
Borders with Style
,
Multiple
styles
,
Border Widths
,
No border at all
,
Border Colors
,
Shorthand Border Properties
,
Global Borders
,
Borders and Inline Elements
,
Padding
,
Colors
,
Affecting Borders
,
Columns
,
Table Cell Borders
,
Border
spacing
,
Collapsing Cell Borders
,
Outlines
,
border-bottom-width
,
border-left
,
border-right-width
,
border-top
,
border-top
,
border-top-width
as foreground of
element,
Colors
background extending
to,
Borders
color of,
Basic Boxes
,
Borders
,
Borders with Style
,
Affecting Borders
enabling existence
of,
No border at all
for columns and column
groups,
Columns
for inline replaced
elements,
Adding box
properties
for inline-level
elements,
Adding box
properties
,
Borders and Inline Elements
for table cells,
Table Cell Borders
,
Border
spacing
,
Collapsing Cell Borders
padding
and,
Padding
sides of,
Global Borders
,
border-top
style of,
Multiple
styles
,
border-bottom-width
,
border-left
,
border-right-width
,
border-top
transparent,
Border Colors
width
of,
Borders
,
Border Widths
,
Shorthand Border Properties
,
border-top-width
bottom
alignment,
Bottom
feeding
boxes,
Block-level
elements
,
Absolute Sizes
,
Assigning values to line-height
,
Basic Terms and Concepts
,
Inline Formatting
,
Inline Nonreplaced Elements
,
Building the boxes
,
Managing the
line-height
,
Inline Replaced Elements
,
Table arrangement
rules
,
Table arrangement
rules
,
System Fonts
,
Defining the page
size
,
Page-breaking
behavior
,
Repeated
elements
column
boxes,
Table arrangement
rules
dialog
boxes,
System Fonts
em boxes (em
squares),
Absolute Sizes
line boxes,
Assigning values to line-height
,
Basic Terms and Concepts
,
Inline Formatting
,
Inline Nonreplaced Elements
,
Building the boxes
,
Managing the
line-height
,
Inline Replaced Elements
,
Page-breaking
behavior
page boxes,
Defining the page
size
,
Repeated
elements
row boxes,
Table arrangement
rules
braces ({}) in property syntax,
Using Code Examples
brackets ([]),
Property Conventions
,
Attribute Selectors
in attribute selectors,
Attribute Selectors
in property
syntax,
Property Conventions
Braille media type,
Attributes
breaks,
Block-level
elements
,
Page
breaking
,
orphans
,
page-break-before
generated by block-level
elements,
Block-level
elements
page breaks,
Page
breaking
,
orphans
,
page-break-before
browsers,
Element Display Roles
,
Attributes
,
Deciding Between Class and ID
,
Attribute Selectors
,
Inheritance
,
Named Colors
,
Relative Length Units
,
Stretching and Adjusting Fonts
,
Font-Face Rules
,
Weird Decorations
,
Computed values
,
Transparent
borders
,
Padding and Replaced Elements
,
Affecting Form Elements
,
Interesting
effects
,
Element Visibility
,
Fixed Positioning
,
List-Marker Positions
,
Generated Content
,
Specifying Content
,
Outlines
,
Outlines
as screen-medium user
agents,
Attributes
attribute selectors,
Attribute Selectors
,
Affecting Form Elements
clipping,
Element Visibility
color
names,
Named Colors
escaped
content,
Specifying Content
font face rules not implemented
by,
Font-Face Rules
generated content,
Generated Content
inheritance support,
Inheritance
list-style-type
defaults,
List-Marker Positions
nonrectangular
outlines,
Outlines
older versions
of,
Deciding Between Class and ID
outline
placement,
Outlines
padding for
images,
Padding and Replaced Elements
pixel preference settings
in,
Relative Length Units
printing
fixed-attachment backgrounds,
Interesting
effects
run-in
elements,
Computed values
stretching and adjusting fonts not
implemented,
Stretching and Adjusting Fonts
text
decorations,
Weird Decorations
transparent
borders,
Transparent
borders
z-axis
positioning,
Fixed Positioning
bugs,
Multiple Classes
,
Inheritance
,
Relative Sizes
,
Padding
,
Interesting
effects
borders drawn away from padding in Navigator
4,
Padding
default font size in Internet
Explorer,
Relative Sizes
fixed-attachment
backgrounds on non-body elements handled
incorrectly,
Interesting
effects
multiple class selector handling in Internet
Explorer,
Multiple Classes
styles not inherited into
tables,
Inheritance

Other books

A String in the Harp by Bond, Nancy
Wielder's Fate by T.B. Christensen
Sun Burnt by Cat Miller
Raphael by D. B. Reynolds
El libro negro by Giovanni Papini
IMMORTAL MATCHMAKERS, INC. by Mimi Jean Pamfiloff
Cowgirl Come Home by Debra Salonen - Big Sky Mavericks 03 - Cowgirl Come Home
The Music Lesson by Katharine Weber