Read CSS: The Definitive Guide, 3rd Edition Online

Authors: Eric A. Meyer

Tags: #COMPUTERS / Web / Page Design

CSS: The Definitive Guide, 3rd Edition

BOOK: CSS: The Definitive Guide, 3rd Edition
4.97Mb size Format: txt, pdf, ePub
ads
CSS: The Definitive Guide, 3rd Edition
Eric A. Meyer
Editor
Tatiana Apandi

Copyright © 2009 O'Reilly Media, Inc.

O'Reilly Media
Dedication

To my wife and daughter and all the joys they bring me
.

Preface

If you are a web designer or document author interested in sophisticated page styling,
improved accessibility, and saving time and effort, this book is for you. All you really
need before starting the book is a decent knowledge of HTML 4.0. The better you know HTML,
of course, the better prepared you'll be. You will need to know very little else to follow
this book.

This third edition of
CSS:
The Definitive Guide
covers CSS2 and CSS2.1 (up through the 11 April
2006 Working Draft), the latter of which is, in many ways, a clarification of the first.
While some CSS3 modules have reached Candidate Recommendation status as of this writing, I
have chosen not to cover them in this edition (with the exception of some CSS3 selectors).
I made this decision because implementation of these modules is still incomplete or
nonexistent. I feel it's important to keep the book focused on currently supported and
well-understood levels of CSS, and to leave any future capabilities for future editions.

Conventions Used in This Book

The following typographical
conventions are used in this book:

Italic

Indicates new terms, URLs, variables in text, user-defined files and
directories, commands, file extensions, filenames, directory or folder names,
and UNC pathnames.

Constant width

Indicates command-line computer output, code examples, Registry keys, and
keyboard accelerators.

Constant width bold

Indicates user input in examples.

Constant width italic

Indicates variables in examples and in Registry keys. It is also used to
indicate variables or user-defined elements within italic text (such as
pathnames or filenames). For instance, in the path
\
Windows
\
username
, replace
username with your name.

Tip

This icon signifies a tip, suggestion, or general note.

Warning

This icon indicates a warning or caution.

Property Conventions

Throughout this book, there are boxes that break down a
given CSS property. These have been reproduced practically verbatim from the CSS
specifications, but some explanation of the syntax is in order.

Throughout, the allowed values for each property are listed with the following
syntax:

Value: [ |
thick
|
thin
]{1,4}
Value: [ , ]*
Value: ? [ / ]?
Value: ||

Any words between "<" and ">" give a type of value or a reference to another
property. For example, the property
font
will accept
values that actually belong to the property
font-family
. This is denoted by the text . Any words
presented in
constant width
are keywords that must
appear literally, without quotes. The forward slash (/) and the comma (,) must also be
used literally.

Several keywords strung together means that all of them must occur in the given
order. For example,
help me
means that the property
must use those keywords in that exact order.

If a vertical bar separates alternatives (X | Y), then any one of them must occur. A
vertical double bar (X || Y) means that X, Y, or both must occur, but they may appear in
any order. Brackets ([...]) are for grouping things together. Juxtaposition is stronger
than the double bar, and the double bar is stronger than the bar. Thus "V W | X || Y Z"
is equivalent to "[ V W ] | [ X || [ Y Z ]]".

Every word or bracketed group may be followed by one of the following modifiers:

  • An asterisk (
    *
    ) indicates that the preceding
    value or bracketed group is repeated zero or more times. Thus,
    bucket*
    means that the word
    bucket
    can be used any number of times, including zero. There is no
    upper limit defined on the number of times it can be used.

  • A plus (
    +
    ) indicates that the preceding
    value or bracketed group is repeated one or more times. Thus,
    mop+
    means that the word
    mop
    must be used at least once, and potentially many more times.

  • A question mark (
    ?
    ) indicates that the
    preceding value or bracketed group is optional. For example,
    [pine tree]?
    means that the words
    pine tree
    need not be used (although they must appear
    in that exact order if they are used).

  • A pair of numbers in curly braces (
    {M,N}
    )
    indicates that the preceding value or bracketed group is repeated at least
    M
    and at most
    N
    times. For example,
    ha{1,3}
    means
    that there can be one, two, or three instances of the word
    ha
    .

Some examples follow:

give
||
me
||
liberty

At least one of the three words must be used, and they can be used in any
order. For example,
give liberty
,
give me
,
liberty me
give
, and
give me liberty
are all
valid.

[ I | am ]? the || walrus

Either the word
I
or
am
may be used, but not both, and use of either is
optional. In addition, either
the
or
walrus
, or both, must follow in any
order. Thus, you could construct
I the
walrus
,
am walrus the
,
am the
,
I
walrus
,
walrus the
, and so
forth.

koo
+
ka-choo

One or more instances of
koo
must be
followed by
ka-choo
. Therefore,
koo koo ka-choo
,
koo koo
koo ka-choo
, and
koo ka-choo
are all legal. The number of
koo
s is
potentially infinite, although there are bound to be implementation-specific
limits.

I really{1,4}? [love | hate] [Microsoft | Netscape |
Opera | Safari]

This is the all-purpose web designer's opinion expresser. This example can
be interpreted as
I love Netscape
,
I really love Microsoft
, and similar expressions.
Anywhere from zero to four
really
s may be
used. You also get to pick between
love
and
hate
, even though only
love
was shown in this example.

[[Alpha || Baker || Cray],]{2,3} and Delphi

This is a potentially long and complicated expression. One possible result
would be
Alpha, Cray, and Delphi
. The comma
is placed because of its position within the nested bracket groups.

Using Code Examples

This book is here to
help you get your job done. In general, you may use the code in this book in your
programs and documentation. You do not need to contact us for permission unless you're
reproducing a significant portion of the code. For example, writing a program that uses
several chunks of code from this book does not require permission. Selling or
distributing a CD-ROM of examples from O'Reilly books does require permission. Answering
a question by citing this book and quoting example code does not require permission.
Incorporating a significant amount of example code from this book into your product's
documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the
title, author, publisher, and ISBN. For example: "
CSS: The Definitive
Guide
, Third Edition, by Eric A. Meyer. Copyright 2007 O'Reilly Media, Inc.,
978-0-596-52733-4."

If you feel your use of code examples falls outside fair use or the permission given
above, feel free to contact us at
[email protected]
.

How to Contact Us

We at O'Reilly
have tested and verified the information in this book to the best of our ability, but
you may find that features have changed (or even that we have made mistakes!). Please
let us know about any errors you find, as well as your suggestions for future editions,
by writing to:

O'Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

There is a web page for this book,
which lists errata, examples, or any additional
information. You can access this page at:

http://www.oreilly.com/catalog/csstdg3

To comment or ask technical questions about this book, send email to:

[email protected]

For more information about books, conferences, Resource Centers, and the O'Reilly
Network, see the O'Reilly web site at:

http://www.oreilly.com
Safari® Enabled

When you see a Safari® Enabled icon on the cover of your favorite technology book,
that means the book is available online through the O'Reilly Network Safari Bookshelf.

Safari offers a solution that's better than e-books. It's a virtual library that lets
you easily search thousands of top tech books, cut and paste code samples, download
chapters, and find quick answers when you need the most accurate, current information.
Try it for free at
http://safari.oreilly.com
.

Acknowledgments

I'd like to take a moment to thank the people who have backed me up during the long
process of getting this book to its readers.

First, I'd like to thank everyone at O'Reilly for all they've done over the years,
giving me my break into publishing and continuing to give me the opportunity to produce
a book that matters. For this third edition, I'd like to thank Tatiana Apandi for her
good humor, patience, and understanding as I played chicken with my deadlines.

I'd also like to thank most profoundly my technical reviewers. For the first edition,
that was David Baron and Ian Hickson, with additional input from Bert Bos and Håkon Lie.
The second edition was reviewed by Tantek Çelik and Ian Hickson. The fine folks who
performed technical review on the third edition, the one you hold in your hands, were
Darrell Austin, Liza Daly, and Neil Lee. All lent their considerable expertise and
insight, keeping me honest and up-to-date on the latest changes in CSS as well as taking
me to task for sloppy descriptions and muddled explanations. None of the editions, least
of all this one, could have been as good as it is without their collective efforts, but
of course whatever errors you find in the text are my fault, not theirs. That's kind of
a cliché, I know, but it's true nonetheless.

Similarly, I'd like to thank everyone who pointed out errata that needed to be
addressed. I may not have always been good about sending back email right away, but I
read all of your questions and concerns and, when needed, made corrections. The
continued feedback and constructive criticism will only help the book get better, as it
always has.

There are a few personal acknowledgments to make as well.

To the staff of WRUW, 91.1 FM Cleveland, thank you for nine years of support, great
music, and straight-out fun. Maybe one day I'll bring Big Band back to your airwaves,
and maybe not; but either way, keep on keepin' on.

To Jeffrey Zeldman, thanks for being a great colleague and partner; and to the whole
Zeldman family, thanks for being such wonderful friends.

To "Auntie" Molly, thanks for always being who you are.

To "Uncle" Jim, thanks for everything, both professionally and personally. It's no
exaggeration to say I wouldn't be where I am without your influence, and our lives would
be a good deal poorer without you around.

To the Bread and Soup Crew—Jim, Genevieve, Jim, Gini, Ferrett, Jen, Jenn, and
Molly—thanks for all your superb cooking and tasty conversation.

To my extended family, thank you as always for your love and support.

To anyone I should have thanked, but didn't: my apologies. And my thanks.

And to my wife and daughter, more thanks than I can ever express for making my days
richer than I have any right to expect, and for showering me with more love than I could
ever hope to repay. Though I'll keep trying, of course.

Cleveland Heights, Ohio

1 August 2006


—Eric A. Meyer
BOOK: CSS: The Definitive Guide, 3rd Edition
4.97Mb size Format: txt, pdf, ePub
ads

Other books

A Kind of Justice by Renee James
The Shamrock & the Rose by Regan Walker
Darkest Powers Bonus Pack 2 by Armstrong, Kelley
Open Skies by Marysol James
Forbidden Love by Maura Seger
Raven's Ransom by Hayley Ann Solomon
Excess Baggage by Judy Astley
Twenty-Seven Bones by Jonathan Nasaw