Oakland.pm

Reviews

Review of "Cascading Style Sheets: The Definitive Guide"

author: Eric Meyer

reviewer: George Woolley


Cascading Style Sheets: The Definitive Guide, 2nd Edition
By Eric Meyer
2nd Edition March 2004
ISBN: 0-596-00525-3
528 pages, $39.95 US, $57.95 CA, £28.50 UK

Short Review

Smiley Rating:    :) :) :) :) of 5

If you have some experience creating web pages and have a reasonably good grasp of HTML and are really serious about getting deep into CSS, this would be a really good book to do that with.

On the other hand, if you're looking for a CSS cook book or for a basic CSS tutorial for beginners, this is not the book for you.

While not a CSS expert, I've been using CSS to develop websites for a number of years. I've found this book most valuable in deepening my understanding of CSS.

If you want more detail, you could take a look at my somewhat longer review.

George Woolley of Camelot.pm and Oakland.pm

Miscellaneous

Chapters and Appendixes

  • 1. CSS and Documents
  • 2. Selectors
  • 3. Structure and the Cascade
  • 4. Values and Units
  • 5. Fonts
  • 6. Text Properties
  • 7. Basic Visual Formatting
  • 8. Padding, Borders, and Margins
  • 9. Colors and Backgrounds
  • 10. Floating and Positioning
  • 11. Table Layout
  • 12. Lists and Generated Content
  • 13. User Interface Styles
  • 14. Non-Screen Media
  • A. Property Reference
  • B. Selector, Pseudo-Class, and Pseudo-Element Reference
  • C. Sample HTML 4 Style Sheet

Notes:

Links to Fun Stuff

Why isn't olfactory presentation addressed in the CSS spec? Is this an indication of a prejudice toward smell? Ooops, that's not a link.

Why isn't the octothorpe used for comments in CSS? Wooops, that's not a link either. (Actually, using the octothorpe to mark comments would create problems.)

OK, I said links, so here are some fun links

Oh, don't confuse Grue in "Warding Off the Grue" with Grues in "Even Grues Get Full".   ;)

By the way, what does CSS stand for? Content Scrambling System?

Some Useful Links

Here are some useful links associated with the author.

And here's, perhaps, the most important link of all

Note:

  • W3C stands for World Wide Web Consortium. Likely, you knew that.

Infamous Browsers

  • IE
  • Netscape 4.x

Note:

  • That is, infamous regarding CSS support.

Warning about Editions

The book being reviewed here is the second edition and was published March 2004.

When reading other reviews of this book, try to determine which edition is being reviewed. For example, if the review is dated 2000, 2001, 2002 or 2003, then the review is presumably of the first edition.

Hopefully no one will try to sell you a first edition without pointing out there's a second edition. But who knows? To be safe, I recommend checking which edition is being offered.

Somewhat Longer Review

Contents

Note:

What Are Cascading Style Sheets (CSS)?

In this section I say what cascading style sheets are at all and briefly explain a few terms which will help in understanding this review.

A cascading style sheet consists of a set of rules that help a browser to know how to present the markup (e.g. HTML) it applies to.

There can be multiple style sheets. For example, there can be a user style sheet, an author style sheet and a browser style sheet.

Document Tree Structure: An HTML page can be viewed in terms of elements within elements. Consider the following HTML

<body>
   <h2>Cats</h2>
   <p>Cats always have three names.</p>
   <p>Somewhere, there is a <em>cat</em> on a mat.</p>
</body>

In this example, there are 5 elements. The body element contains an h1 header element and two paragraph elements. The second paragraph element, in turn, contains an em element.

This can be represented as a tree structure.

             body
             |
         -----------
         |    |    |
         h2   p    p
                   |
                   em

Well, that's not much of a tree. Such trees can, of course, be way more complex than that.

Selectors and Properties: The following is an example of a CSS rule

h2 {
     color: blue;
     font-size: large;
}

This rule says that h2 headings should be blue and large. The h2 in this rule is called a selector; that's because it selects the markup the rule is intended to apply to. In the body of this rule, two specific properties are specified for h2 elements: color and font-size.

Values and Units: Above, blue and large are values (of properties).

The large could be replaced with a more specific value such as .5in or 16px. In these more specific values in and px are short for the units inches and pixels.

Cascading: Multiple style sheets can apply to the same page. Even within a particular style sheet there can be multiple rules that could apply to a particular property of a particular element.

Cascading addresses the question which rules actually apply.

Inheritance: In the example given earlier, we say that the body element is the parent of the h2 element and of two p elements and we say that the second p element is the parent of the em element. (Sadly, from this point of view, each element has only one parent. Oh, well.)

Under certain circumstances and depending on the CSS, elements can take on certain property values from their parents. This is called inheritance.

Advantages: One way to look at CSS is that it's a way to get better separation between layout & styles on the one hand and content & semantic structure on the other hand and a way to get certain benefits such as

  • ease of maintenance (especially when multiple files are involved)
  • faster download time
  • better indexing by search engines
  • greater control over layout and styling

Aside: I admit it. This whole section about what CSS is at all is taken from an earlier review I wrote.

I have made a number of additions and changes. Still, this is a clear cut case of self-plagiarism.  ;)

The Cover

Cascading Style Sheets: The title implies that the topic focused on in this book is Cascading Style Sheets. See the previous section for a little about CSS.

Definitive Guide: Based on the title and the fact this book was published by O'Reilly, this should be an O'Reilly Definitive Guide. This implies that it should be an in depth book on a specific topic.

Other Things on the Cover: On my cover it also says

  • Visual Presentation for the Web
  • 2nd Edition
  • Covers CSS2 & CSS2.1

The words "Visual Presentation for the Web" indicate that the focus is on those aspects of CSS that have to do with the visual layout and styling of web pages.

The words "2nd Edition" indicate there is an earlier edition. One might reasonably assume that there have been enough improvements to warrant calling this book a second edition.

CSS2 and CSS2.1 are versions of the CSS specification. The words "Covers CSS2 & CSS2.1" indicate that these W3C specifications are covered.

Can you judge this book by its cover?: Well, the topic of the book is certainly Cascading Style Sheets and it goes deeper into them than any other book I've looked at.

Oh, and as suggested, this book does focus on visual presentation on the web (i.e., web pages). (However paged media and possible future aural presentation are also covered.) And yes, this book does address the features of CSS 2 and CSS 2.1.

There was a first edition in 2000. But while there are many similarities between the two editions, the second edition appears to be a complete reworking and updating of the first edition.

About the Reviewer

design background: OK, I

  • am webmaster of a number of non-profit sites
  • have been using CSS for a number of years
  • tend to keep HTML/CSS simple

I use CSS extensively. It really makes my life easier. However, I'm not a professional web designer.

publisher: I own a number of O'Reilly books and they've served me well. I have reviewed a number of O'Reilly books. I'm a big fan of O'Reilly.

OS and browsers: The browsers I use the most, in order of my usage, are:

  • Firefox (on Linux)
  • Konqueror (on Linux)
  • Safari (on Mac OS X)
  • IE (on Windows)

reviews: Last year, I reviewed two CSS books:

Both are very good books. Neither has the same function as the book being reviewed.

What You Get

A Story with a Moral: There's an old joke about a little boy who comes home from school and his mother asks him "What did you learn in school today?" The little boy answers "Mommy today I learned more about dolphins than I'll ever want to know." Very cute. :)

The thing is that this book contains more about CSS than most people will ever want to know. Valuable stuff for those who want to know it, but ...

Hm, you probably want something a bit more specific than that. OK, I'll give it a shot.

CSS Basics: The book begins by presenting what I consider to be CSS basics including (but certainly not limited to)

  • Why CSS?
  • Document Tree Structure
  • Selectors
  • Inheritance
  • The Cascade
  • Units and values in CSS rules

CSS Presentation: The rest of the body of the book gets into more detail on presentation. Some (again, not all) of the topics addressed are

  • text, fonts
  • layout, padding, borders, margins
  • background
  • lists
  • the user interface
  • paged media

Property Reference: There's also three appendixes. The most important is the property reference which (among other things) has entries for the properties in CSS 2.1 in alphabetic order. (Well, actually, there are 5 properties for tables in a separate list and 5 properties for paged media in another separate list.)

Each entry includes all the following that are relevant

  • a paragraph giving a general idea of the property and its use
  • values
  • initial (i.e. default) value
  • applies to
  • inherited (yes or no)
  • percentages if relevant (whether allowed & where)
  • computed value

What I Like

I like this book a lot. Below I touch on some of the things I like.

Thoroughness: The book goes much deeper than any other CSS book I've read. Reading the book, I kept on formulating new (for me) questions which were usually answered in the next few lines.

Examples: The book contains many CSS coding examples and many examples of what the resulting presentation would look like.

Conceptual Figures: The author effectively uses graphic figures from time to time to get across important concepts. E.g. there are well conceived figures entitled

  • The structure of a rule
  • A document tree structure.
  • A conceptual view of z-index stacking

Info on Problem Browsers: There is a lot of info about browsers that don't fully and/or don't correctly implement particular aspects of CSS.

Occasionally Light: Here's my favorite passage where I was somewhat amused "ID selectors are preceded by an octothorpe (#) -- also known as a pound sign, hash mark, or tic-tac-toe board". And, yes, octothorpe does make it into the index. :) Tic-tac-toe board, however, does not. :(

Useful Learnings: I learned a lot of useful things.

For example, for a long time I've been using a mildly annoying workaround for treating the top margin for a paragraph immediately following a heading different from other paragraphs. The author shows how to do this with an adjacent sibling selector.

If you don't know what I'm talking about, no problem; if you dive into the book you will. At the other extreme, if you know exactly what I'm talking about and do that all the time, I'm betting you'll learn other things from this book.

Attitude of Exploration: There's an attitude of exploration in the book which is contagious. Without the thoroughness and useful learnings, I'm thinking this plus would not come into play.

Gripes

Two Too Long Chapters: Two of the chapters were rather long. More specifically, chapter 7 on "Basic Visual Formatting" is 48 pages long and chapter 10 on "Floating and Positioning" is 55 pages long.

It's not just that the chapters are long, they are also difficult -- or at least, they were for me.

Missing Guidance: In the Preface, I'd like to see a section which says how the book is designed to be used and makes suggestions on how to get the most out of it. More specifically, do the chapters need to be read in strict order or is it OK to jump around?

Sometimes Confusing: I'm not sure exactly why, but in a number of places, I found this book confusing. Sometimes, by rereading and by pondering what I'd read, I was able to clear up my confusion -- sometimes, not.

Who's the Book for and not for?

for: I'd say this book is best for people who already have a good grasp of CSS and want to go deeper.

According to the preface, this book is for readers who

  • are web designers or document authors
  • have a good knowledge of HTML
  • want to create pages with sophisticated styling
  • want to create pages which are accessible
  • want to save time and effort

Sounds workable to me, though I would hope that the reader's desire for sophisticated styling ran deep.

not for: This book is not for the light of heart. You need to be quite serious about CSS, for whatever reason.

If you are just learning CSS likely this book is not for you. Certainly not if what you're looking for is a beginning tutorial. There are a number of tutorials on the web, e.g., W3Schools has one at W3Schools CSS Tutorial. One way to find them would be to do a search(es) on your favorite search engine, e.g. a search on "CSS online tutorial".

If what you really want is a CSS cook book, this book is also not for you. However, I suggest checking out the catalog entry for CSS Cookbook (published by O'Reilly). Or you could look at my review of it.

Final Thoughts

This book is really good for what it is, that is, an O'Reilly Definitive Guide for CSS. If you want a thorough deep coverage of CSS, this book delivers!

If that's not what you want and you evaluate this book in terms of your interests, you may well conclude that this book "sucks".   :(  :)

Smiley Rating:    :) :) :) :) of 5

Announced Draft: 2005-04-18

Completed: 2005-04-26