Book Review: CSS Cookbook, O’Reilly Media
by Peter Lavin
Originally published at TheUKWebDesignCompany.com
Like many developers, I am familiar with O’Reilly books and have come to expect high quality material from this publisher. I know their “Cookbook” format of books, having made extensive use of the “PHP Cookbook”. To top it all off, my standard reference for CSS is published by this publisher. So, needless to say, when trying to decide upon another CSS book I was naturally drawn towards O’Reilly.
One nice feature that O’Reilly Media offers is the ability to read portions of their books online. Sure enough, Chapter 2 of “CSS Cookbook” by Christopher Schmitt was available to be read at the O’Reilly site. Having a quick look at this chapter, a couple of things jumped out at me. The different way in which the hr tag is handled by Netscape (NS) and Internet Explorer (IE) and also the use of the background-position property of a background-image. Struggling with problems related to both these items was still fresh in my mind.
Reading the intentions expressed in the preface:
“With this book, web builders can solve common problems associated with CSS-enabled web page designs.”
I decided that this was the book I wanted.
Web developers look to CSS to help simplify their lives - it can save a lot of time in development and maintenance. I always look forward to manipulating the presentation of a website using as much CSS as possible because, when I have to make those inevitable changes, my life will be much simpler.
With these thoughts in mind I approached the chapter on printing web pages. This is certainly an area that could do with simplification but my attention strayed as I imagined other, less complex and more obvious, non-CSS solutions than those presented here. Perhaps I didn’t give this chapter the attention it deserves but it certainly wasn’t through reluctance to use CSS technology but because CSS does not yet offer a quick and easy solution.
Some of the other solutions presented here seemed unnecessarily obtuse. Setting the display property of a span element to block seems to subvert the whole purpose of a span element. Why not just use a div instead? Likewise hiding the text in an h1 element and then setting the background-url to an image just seems like a roundabout way of using the img tag.
Early on in the book we are introduced to the pseudo element, first-letter. While this is an element that is supported by IE 6 and later versions of both NS and FireFox, we are quickly given a workaround because of incompatibility with NS 4. Isn’t the more interesting and useful discussion the one about how first-letter is implemented differently by the more current browsers? Isn’t this the workaround that should be given?
Likewise, in chapter 5, an otherwise useful discussion of a login form, is marred by the introduction of the pseudo element, after. It is used with no mention of the fact that it is not supported by IE 6. Apart from knowing that after is a part of the CSS standard, the most important thing to know about it is this lack of support.
While discussing the pseudo elements “hover” and “visited” the author makes this observation:
“:hover and “:active” may be applied to any element ... Note that ... support
is non-existent in Netscape Navigator 4.”
This is undoubtedly true but more importantly, again, “What about IE 6?” The implication of this statement is that IE 6 supports hover not only for anchors but for all elements. This is not the case, and is certainly much more important to the developer than what is or isn’t supported in NS 4.
In a similar vein, in chapter 10.06 max-width is simply described as the property that “constrains the width of the div element” – if only this were true for IE 6.
Overall, there is far too much attention paid to NS 4 and earlier browsers. In my view, this emphasis renders the whole discussion of Chapter 9, “Hacks and Workarounds”, irrelevant. I would guess that there are many more people currently using FireFox than NS 4 and there is nary a mention of this browser in the entire book. This may be a bit unfair since FireFox has only reached a high level of popularity in recent months and the “CSS Cookbook” was published in August of 2004. Nevertheless, FireFox certainly created plenty of buzz prior to this date and was easily spotted as a possible contender to IE.
All in all, isn’t it about time we forgot about NS 4 entirely? Later versions of this browser are freely available for virtually all operating systems. Let any Luddite who persists in using it live with the consequences.
The Baby in the Bathwater
The discussion of layouts without the use of tables shows a healthy recognition of the limitations of the div tag. Also, there is no lecture about the political incorrectness of page designs based on tables. Table-based page designs will continue to be used because in some cases they are the only tool for the job.
This book was put together with little attention paid to IE 6. I myself am no fan of Microsoft but you cannot develop web applications and ignore this browser. Its market dominance may be waning slightly but it is still far and away the most popular browser in use.
Like the author of this book I am a proponent of CSS and lament the fact that it is not more widely supported. max-width is a very useful feature and I have often wished that hover was supported by IE for all elements. However, until IE 6 is relegated to the scrap heap, it does no-one any good to blithely promote the use of style elements that are not supported by IE 6, especially when there are no easy workarounds.
A cookbook of recipes aimed at web developers is not the proper place for promoting the use of CSS elements with limited browser support. Nor are developers particularly interested in workarounds for NS 4. If you are serious about using CSS you have probably written off NS 4 anyway. So, quite simply, I would have to say that this book doesn’t live up to the intentions expressed in the preface. Undoubtedly there is some useful content, but this book is certainly not up to the standard one has come to expect from O’Reilly Media.
About the Author
Peter Lavin runs a Web Design/Development firm in Toronto, Canada. He has been published in a number of magazines and online sites, including UnixReview.com, php|architect and International PHP Magazine. He is a contributor to the recently published O'Reilly book, PHP Hacks and is also the author of Object Oriented PHP, published by No Starch Press.
Please do not reproduce this article in whole or part, in any form, without obtaining written permission.
Copyright © 2017 softcoded -
the Toronto web design & development company