CSS: The Definitive Guide
Michael J. Ross writes "Every Web developer knows that Cascading Style Sheets (CSS) makes it possible to separate the contents of Web pages from the styling of the elements on those pages. This in turn confers tremendous advantages, such as allowing site-wide changes of appearance to be made just once, in a single stylesheet file, rather than in all of the pages containing the affected elements. The syntax and proper usage of CSS is not as simple as implied by many HTML/CSS books, most of which fail to provide enough detail as to how CSS is applied to page elements. Web developers relying upon these books soon find themselves hitting those limits, and becoming frustrated when trying to debug Web pages. CSS: The Definitive Guide, authored by CSS expert Eric A. Meyer, aims to fill that gap." Read on for the rest of Michael's review.
CSS: The Definitive Guide
author
Eric A. Meyer
pages
536
publisher
O'Reilly Media
rating
9
reviewer
Michael J. Ross
ISBN
0596527330
summary
A comprehensive CSS reference guide.
Published by O'Reilly Media in November 2006, this title is now in its third edition. The first edition appeared in May 2000, and the second in January 2004 — with each one establishing the book as an immediate favorite among hard-core Web programmers. Each revision brought it up to date with the evolution of CSS as a standard, its support among the most popular Web browsers, and its usage within the Web development community. This latest edition covers CSS2 and CSS2.1, but does not include the CSS3 modules, including those that have reached Candidate Recommendation status, because their implementation is largely incomplete among most of the browsers.
Web veteran Eric Meyer presents the book's material in a methodical manner, starting with an overview of CSS's purpose and advantages, and quickly moving into the details of the technology: selectors, structure, inheritance, values, units, fonts, text properties, visual formatting, padding, borders, margins, colors, backgrounds, floating, positioning, tables, lists, and generated content (e.g., bullets of unordered lists). The last two chapters address user interface styles (system fonts and colors, cursors, and outlines) and non-screen media (such as paged and aural content). The book's 536 pages are organized into a total of 14 chapters and three appendices. The first appendix is a complete CSS property reference, spanning more than 40 pages, with visual, page, and aural properties grouped separately. For each property, Meyer explains its purpose, its valid values, the initial value, what elements it applies to, whether it is inherited, its computed value, and additional notes (if any). The second appendix is a reference for the selectors, pseudo classes, and pseudo elements. The third and final appendix is much shorter than the first two, but no less interesting, as it discusses a sample HTML 4 stylesheet, which is presented in the CSS2.1 specification as the recommended style sheet for developers to use.
As with all of their other titles, O'Reilly Media offers a Web page devoted to this book, where visitors will find links to online versions of the book cover, table of contents, index, registration form, reader reviews, and errata (of which there are none, as of this writing). In addition, the page has offers to receive a volume discount, and to read the book online as part of O'Reilly's Safari service.
Anyone who is considering purchasing this book might initially be concerned by the dearth of feedback on the Web sites of the publisher and the major online booksellers — in the form of few reader comments, and no reported errata. The prospective reader may wrongly conclude that this indicates a lack of interest in the book, and thus it must be unpopular — probably for good reason. But just the opposite is true, as demonstrated by the book's sales rank on Amazon.com alone: #4631, as of this writing. Unlike far too many of the other HTML/CSS books available, this one does not engender scathing reviews by customers angry with the books' shoddy writing and sloppy mistakes. Rather, Meyer's contribution is the type of solid reference book that the discerning Web developer will quietly place on their desk or bookshelf, within easy and frequent reach — possibly displacing a dog-eared first or second edition of the same title. Furthermore, the absence of errata should suggest that most if not all kinks have been worked out of the book, and not that the book is failing to receive careful readings.
CSS: The Definitive Guide benefits not just from its multiple revisions, but also from Eric Meyer's clear and complete writing style. Unlike his more advanced books, this one is far more approachable, making it possible for the reader to easily jump into the midst of any topic and quickly pick up the thread — as is essential for any technical reference work. The theoretical discussions and the sample code demonstrate his abundant experience in using CSS in the real world, discovering or verifying its idiosyncrasies, and pushing it to its limits. Most of the critical visual and positioning topics are well illustrated with diagrams and sample output, few of which are weakened by the lack of color in the grayscale figures. Last and certainly not least, readers should be pleased that the book's material has been updated for Internet Explorer 7, which promises to fix many inexcusable problems in earlier versions of the browser.
Rarely does one come across a programming book that has no significant flaws, and will likely become a favorite resource for developers everywhere. CSS: The Definitive Guide is a comprehensive, well-written, and welcome addition to the library of any Web developer who wishes to understand and utilize CSS better.
Michael J. Ross is a Web consultant, freelance writer, and the editor of PristinePlanet.com's free newsletter. He can be reached at www.ross.ws, hosted by SiteGround.
You can purchase CSS: The Definitive Guide from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Published by O'Reilly Media in November 2006, this title is now in its third edition. The first edition appeared in May 2000, and the second in January 2004 — with each one establishing the book as an immediate favorite among hard-core Web programmers. Each revision brought it up to date with the evolution of CSS as a standard, its support among the most popular Web browsers, and its usage within the Web development community. This latest edition covers CSS2 and CSS2.1, but does not include the CSS3 modules, including those that have reached Candidate Recommendation status, because their implementation is largely incomplete among most of the browsers.
Web veteran Eric Meyer presents the book's material in a methodical manner, starting with an overview of CSS's purpose and advantages, and quickly moving into the details of the technology: selectors, structure, inheritance, values, units, fonts, text properties, visual formatting, padding, borders, margins, colors, backgrounds, floating, positioning, tables, lists, and generated content (e.g., bullets of unordered lists). The last two chapters address user interface styles (system fonts and colors, cursors, and outlines) and non-screen media (such as paged and aural content). The book's 536 pages are organized into a total of 14 chapters and three appendices. The first appendix is a complete CSS property reference, spanning more than 40 pages, with visual, page, and aural properties grouped separately. For each property, Meyer explains its purpose, its valid values, the initial value, what elements it applies to, whether it is inherited, its computed value, and additional notes (if any). The second appendix is a reference for the selectors, pseudo classes, and pseudo elements. The third and final appendix is much shorter than the first two, but no less interesting, as it discusses a sample HTML 4 stylesheet, which is presented in the CSS2.1 specification as the recommended style sheet for developers to use.
As with all of their other titles, O'Reilly Media offers a Web page devoted to this book, where visitors will find links to online versions of the book cover, table of contents, index, registration form, reader reviews, and errata (of which there are none, as of this writing). In addition, the page has offers to receive a volume discount, and to read the book online as part of O'Reilly's Safari service.
Anyone who is considering purchasing this book might initially be concerned by the dearth of feedback on the Web sites of the publisher and the major online booksellers — in the form of few reader comments, and no reported errata. The prospective reader may wrongly conclude that this indicates a lack of interest in the book, and thus it must be unpopular — probably for good reason. But just the opposite is true, as demonstrated by the book's sales rank on Amazon.com alone: #4631, as of this writing. Unlike far too many of the other HTML/CSS books available, this one does not engender scathing reviews by customers angry with the books' shoddy writing and sloppy mistakes. Rather, Meyer's contribution is the type of solid reference book that the discerning Web developer will quietly place on their desk or bookshelf, within easy and frequent reach — possibly displacing a dog-eared first or second edition of the same title. Furthermore, the absence of errata should suggest that most if not all kinks have been worked out of the book, and not that the book is failing to receive careful readings.
CSS: The Definitive Guide benefits not just from its multiple revisions, but also from Eric Meyer's clear and complete writing style. Unlike his more advanced books, this one is far more approachable, making it possible for the reader to easily jump into the midst of any topic and quickly pick up the thread — as is essential for any technical reference work. The theoretical discussions and the sample code demonstrate his abundant experience in using CSS in the real world, discovering or verifying its idiosyncrasies, and pushing it to its limits. Most of the critical visual and positioning topics are well illustrated with diagrams and sample output, few of which are weakened by the lack of color in the grayscale figures. Last and certainly not least, readers should be pleased that the book's material has been updated for Internet Explorer 7, which promises to fix many inexcusable problems in earlier versions of the browser.
Rarely does one come across a programming book that has no significant flaws, and will likely become a favorite resource for developers everywhere. CSS: The Definitive Guide is a comprehensive, well-written, and welcome addition to the library of any Web developer who wishes to understand and utilize CSS better.
Michael J. Ross is a Web consultant, freelance writer, and the editor of PristinePlanet.com's free newsletter. He can be reached at www.ross.ws, hosted by SiteGround.
You can purchase CSS: The Definitive Guide from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This is a great book, but my binding cracked after 2 weeks. Worth buying anyway though.
If you examine the link in the parent's post, it shows that he's using a referral code, kaleidojewel1-20. Scumbag.
I purchased the previous version, and it was truly a clear and concise introduction and mastery of CSS. Mastery in the sense of understanding how CSS works, not in mastery of CSS Cookbook type "fixes". It was much better to learn the fundamentals of CSS before trying to understand why and how the hacks work the way they do. I still keep and use the book as a reference at my desk at work.
je suis parce que j'aime
It has been updated to account for IE7's ideosyncracies, but does it also cover the other browsers well? Every time I've started really using CSS, I 've gotten frustrated by the way each browser decided to support a different subset of CSS so I had to sit there and try everything before figuring out what non-IE-on-Windows browsers would make of the page. Probably the major browsers support much more of the CSS spec, but I was burned so bad last time I haven't wanted to touch it with a ten foot pole in several years.
I am the one true god. However, as an atheist, I don't believe in myself. I guess I have a self-esteem problem.
The book is, as the OP states, excellent.
The problem lies with its index. Actually using the book is very difficult because the Index is so non-inclusive of the subjects within the book.
Worth getting, but be prepared to flip through it a whole lot more than you would if the Index was well written.
My 2 cents.
------ The best brain training is now totally free : )
Want to simplify CSS development? Just make IE disappear. Checking that the CSS works in IE is taking lot of time and is the most frustrating not to mention that you have nothing like Web Developer or FireBug. What to loose your neurons, make your CSS work in IE, hack after hack. bGR@!#!@#! len
... that all the free online resources offer? Is it merely organized data? Is it the examples? I find all of that readily available for many web technologies and even more so for PHP and CSS. Numerous sites exist that cover everything in several ways too. Is this book simply a consolidation of information that is otherwise free via a google search?
Invexi - a Phoenix, AZ based web design and web development company.
The web makes that distinction hazier and hazier. Many of us end up doing both in spite of the fact that we're not really suited to it, unfortunately. Of course, the software lets us get decent results easier and easier all the time, so that helps.
But even just talking about CSS, is doing CSS really just design? With all the stupid CSS tricks you have to play, it seems to me more like cross-platform programming than anything else.
I realize that CSS is not a programming language. More's the pity; if it were a little more like a language then a lot of things that are very hard to do in CSS and require dynamic styles (or at least assignation of styles) to do properly would be very easy. For example, I should be able to say that an element is n% minus the width of another element... But since I can't I have to figure out how many units (typ. pixels) are in n%, then figure out how many units wide the other element is, and then set the width of the element I was trying to size accordingly. And if the element I'm trying to fit in next to is sized in ems instead of px, I have to recalculate this data and resize elements every time the font size is changed.
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
Next time, use a URL proxy service, like the article submitter did for the link to their hosting company.
Believe me, working in a graphic design firm as a web developer, there is a large difference between a designer and a developer. Designers here work almost exclusively in Photoshop and only have to have the most rudimentary understanding of what can and can't be done using XHTML/CSS. I'd say that somebody who is used to looking at XHTML/CSS, coding from scratch, understands inheritance, and how these can be used to accurately reproduce major corporate websites across most any browsing environment qualifies as a developer.
CSS is great in theory and should make sites easier to maintain, but in my experience all this advantage is lost when hacking to get IE to support it. I seem to have to support IE OR the rest of the world's web browsers, but I can't seem to get certain pages to support both. I've had to revert back to HTML tables for my page layouts, and I'll be sticking with that until a more CSS-friendly IE becomes more widespread. I just spend a bit of time familiarising myself with CSS and using it for text styling and some positioning within my tables. I'm sure in a year or two it'll become feasible to use CSS exclusively, and I'm quite looking forward to it.
Drill baby drill - on Mars
Every Web developer knows that Cascading Style Sheets (CSS) makes it possible to separate the contents of Web pages from the styling of the elements on those pages.
Or in the case of MySpace, CSS allows a user to make a website with no content look better by overdosing on the style.
500 dollar reward for tip(s) leading to the arrest of the person(s) who stole my sig.
Yes, I wish CSS had support for if statements. I maintain a website in several languages. Now, if a span with xml:lang="es" appears in an English, French, whatever paragraph, it should be italicized, but if a span inheriting xml:lang="es" appears in a Spanish paragraph, it should be styled the same way as the surrounding text. Unfortunately, there's no simple way to do that in CSS. I have to write dozens of individual rules for each language like body:lang(en) span:lang(es) { font-style: italic; } instead of just declaring "If a span appears with a different xml:lang attribute than surrounding text, italicize, otherwise not".
Just junk food for thought...
If you get the book over O'Reilly's Safari service, what you're saying is very possible! (with the help of some custom CSS and Firefox)
The dangers of knowledge trigger emotional distress in human beings.
My definition of a designer is that their role stops short of writing code, whether that's HTML, CSS, whatever. They don't concern themselves with how something's implemented, because then you find yourself thinking like an engineer, and working in terms of what's most expedient, rather than like an end user, and thinking in terms of what's best.
So if you're using this book, you're a developer, not a designer.
Have you tried italicizing all spans with a lang attribute, then de-italicizing english-in-english, spanish-in-spanish, french-in-french, etc?
span:lang {font-style:italic}
body:lang(en) span:lang(en),
body:lang(es) span:lang(es),
body:lang(fr) span:lang(fr),
body:lang(dk) span:lang(dk) {font-style:normal}
paint with broad strokes, then carve out the exceptions.
(and check the syntax; I've never styled arbitrary xml documents, just ordinary HTML.)
egypt urnash minimal art.
Tables Are Good.
It's basically like the behavior in Excel where you freeze the top columns or something like that. So it's not a bad behavior to have, but like you say the only way to do it is to know ahead of time where everything is. difficult with dynamically generated data.
and so Microsoft embedded like javascript language into their CSS. It's completely non-standard, not supported by anybody else. And I keep wondering when will we something like this in the standard?
Then your designers are better than your developers. A good developer should inherently understand the benefits of clean HTML, as well as the subtleties of what can be accomplished with CSS much better than a designer. Developers are always thinking in terms of code reuse and maintainability (at least if they're any good), whereas a designer is more concerned with how things look and maybe usability. The developer is the one who actually has to refactor HTML mockups from designers into templates, so (s)he is the one that should be concerned about bloated non-reusable HTML.
Good to hear that your design people know the benefits of CSS though.
As a web designer and developer who works alongside several designers, I can assure you that understanding CSS is not a designer's role, but a developer's role. Once you are involved in coding (whether it's a Turing-complete language or simply a markup language) you are a developer. Now, I point my designer coworkers to various tools that will auto generate CSS, but purely for making it easier for me to interpret their intent (instead of relying on things like Photoshop values for text paragraph formatting which do not match CSS), and also so that they know what fonts and settings are viewable by the site's end users.
Here's a rule of thumb:
If you are defining things like this, you're in the designer role:
Font: Gill Sans
Size: 12.5pt
Leading: 20pt
Tracking: 30
Color: Pantone 420C
Whereas if you are defining things like this, you're in the developer role:
h3 {
font-family: "Gill Sans", verdana, arial, helvettica, sans;
font-size: 1.25em;
line-height: 1.33em;
letter-spacing: 0;
color: #CCCCCC;
}
I'm out of my mind right now, but feel free to leave a message.....
If you need a 536 page book to "Master" such a trivial part of web development as page and text formatting then CSS is a failure. Are there any wysiwyg "Html editors" that produce portable CSS? If so, then the book is obsolete.
As any Word(tm) user knows, page layout and text formatting should be done Visually. I don't code in assembler any more. And I shouldn't have to write text-formatting codes. Troff was obsolete years ago! CSS is just Troff on steroids.
CSS is such a pain in the butt we should all go back to using tables. I really think it's easier.
I18N == Intergalacticization
am I the only one that thought this was another countrstrike guide having read the title. LOL
Easy: A designer is the one that hands a developer a 30 MB background image, 16 1MB panels and 100 33K widgets and asks why it takes so long for the page to load.
Intron: the portion of DNA which expresses nothing useful.
Yes, I wish CSS had support for if statements.
Hell, I'd be happy with just named constants for colors and numbers (and maybe even for whole or partial selector expressions?).
And now that we're dreaming here I'd be extra happy with math expressions for numbers especially if they could reference properties from other elements. That is starting to get a little like duplicating the DOM scripting stuff though.
I hate to shill my own stuff, but I recently created a site for ranking programming books based on category(language, api, etc) that I think most developers will find very useful. Basically programmers rank their top 5 books for each category. It's very simple, and hopefully useful. It's in a pain finding quality programming books. The only real resource is browsing/searching through amazon, which can be a real pain.
http://www.programmingbooks.org/
For example, here are the top ranked CSS books: http://www.programmingbooks.org/CSS (not many users have ranked css books)
Being a developer and a designer, I think that an understanding of both facets of the website/blog/whatever process is important to know. I think with the advent of CSS, the boundaries have certainly blured,and as other posts have said, a developer stops at image manipulation, a designer stops at coding. It is probably beneficial for a designer to know the limitations of html and css, in order to not give the developer one hell of a headache. It is also beneficial (although less so) for a developer to have an inkling of good design flow. Hopefully at the end of it all you will end up with a site that is good looking and maneageable. If these two seemingly disparate job descriptions cant harmonize, then you end up with a dog slow site that looks wonderful, but is completely unusable, or you end up with a great functional site that nobody stays at longer than 1 second due to retinal burn. I think to be the most employable, you must know css and html. Most job descriptions I have seen unless for larger teams dont make any distinction, instead wanting a do it all guy or gal.
But even just talking about CSS, is doing CSS really just design?
.style1 {font: size 8pt; } .style2 {font: size 9pt; } .style39029 { font: size 10pt; }
Especially with all the crappy designers out there who use Dreamweaver and really haven't a clue about CSS and could care less.
We're all stuck with
.
.
.
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
Yeah you heard it here 1st. A new acronym, YAMN. CSS is becomming even more of a joke then it already is. And the worst part is that is a cruel joke.
As many have said in this string of posts, without the use of tables, it is no longer a job for the general web creator to create a three column lay out, without being a complete CSS guru and even for them it gives them headaches.
In my estimation, what the designers of CSS have managed to do is crush the life out of the promise that once was the a usable, if slightly clumsy, way to present information.
As an example. Using un-ordered lists to create menus. Its a complete and total hack, and I mean to use the word hack in the most derogitory manner possible. Instead of comming up with a menu framework that was designed from the ground up to be menus they used this stupid hack and think they are so cool. News for you, your not cool, your not smart nor are you clever.
There are elements of CSS that are quite functional and workable, but for the most part its just a cludge and a bad one at that. Lets take for example something that could make all of our lives easier, the basic ability to have include files. All you CSS lovers hate frames and you hate tables. Well with frames I can make ONE file contain the entire drop down menu section. I create it in one file and ONLY one file. I edit it in ONE file and ONE file only. So while you geniouses are comming up with HTML, DHTML, XHTML, CSS1, CSS2, etc. ad nausium, you cant seem to fit that simple part in there. Every freeking page has to have the complete menuing system in it and if anything has to be changed in it, like CONTENT someone has to go and edit 1 to n freeking html files, sorry, but for that you guys just plain SUCK.
Now I just know someone will think in regard to that last bit, that it should just be in a database! Well sure as shootin! Except why on fucking earth does a 10 page web site need to have a complete CRM system behind it? Why should it even have a database! Then you will say, but it is only 10 pages, you should write a VI or better yet an EMACS macro to handle that. Better yet anyone who would suggest that should get rectaly examined by the phalus of a donky. UL's twisted into menu's are not trivial and can be broken quite easily. Develop a MENU interface if you are determiend to turn something loosley associated with desktop publishing into a full on interactive bit of software.
The bottom line is this, if you want people to really embrace CSS then FIX IT. Get the venders to fix the browsers and if they wont fix it, then stop twisting CSS all over itself to accomodate them and just let it those browsers fail and the market will fix it.
Hey KID! Yeah you, get the fuck off my lawn!
point 3: the referral doesn't affect the price.
If I buy the book through that link, I'll save $6.30. How is that bad? The fact that someone else makes a some money in the process doesn't adversely affect me (in fact it save me money).
Do you even lift?
These aren't the 'roids you're looking for.
A designer who has only a rudimentary understanding of what can and can't be done using XHTML/CSS is only a rudimentary Web designer.
bad sig...no donut.
A better conclusion:
Specifically, if IE supported display: table-cell et.al., such a layout should indeed be quite trivial. But support for this is apparently still missing, despite the fact that the relevant spec is more than 5 years old.
Using Dreamweaver is not the problem. It's the designers, entirely. Many designers/developers, etc. use Dreamweaver and know all about CSS.
I bought both the Definitive Guide and also the Pocket Reference. They're both by Meyer - the Pocket Reference packs all the vital info into 128 pages. And it really IS a pocket reference, in that it literally fits in my back pocket.
The index in the pocket reference is good. It's got everything I need. But if it didn't, I could give them feedback: there's a line at the bottom saying "We'd like to hear your suggestions for improving our indexes. Send email to index@oreilly.com."
I think I'll send them an email saying that the correct plural of "index" is "indices." Mwa ha ha ha.
"IE7 is no better. Still no border-radius?"
Oh whaaaa! MS doesn't support -moz-border-radius, or -o-border-radius. So much for supporting standards.
The current Working Draft of the CSS3 Values and Units module allows for a calc() function that permits this behavior. Generally, yes, many things would be easier if an embedded programming language would be allowed, but this would potentially come at a significant speed cost. Part of the idea behind CSS is that it should not greatly slow down rendering as compared to simpler layout schemes.
MediaWiki developer, Total War Center sysadmin
If this is a valid CSS3 selector, I think it will do what you want, but I'm not totally clear on where function-style syntax is allowed: body:not([lang|=attr(lang)) span[lang] {...}. Of course, it won't work for languages declared using anything but the lang attribute, but it might be a start.
MediaWiki developer, Total War Center sysadmin
It's funny that you should blame Meyer for suggesting that the technology be used the way it was intended to be used, rather than blaming MS for creating a browser with poor CSS support which forces developers to, as you say, spend time debugging code across browsers. Incidentally, try adding a border, margin and padding to a fixed-width table and see how well that displays cross-browser...
I'd frankly be happy with some pretty damned simple expressions. I just want to be able to refer to elements by ID (and offset or otherwise manipulate them) so that I can base certain values on values in other elements. Is that so wrong? :)
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
I think the issue (such that it is) falls under the category of "conflict of interest." If you're writing a book report, and giving it a glowing review, and providing a link that will give you money if people buy the book, it becomes more difficult to accept the glowingness of the review on its own terms.
It's not a huge deal to me, but it may be to some people.
You want the truthiness? You can't handle the truthiness!