Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
GUI Books Media Programming Software Book Reviews IT Technology

The CSS Anthology 169

Bruce Lawson writes "I've read a lot of CSS books, but this one is the one I wished that I'd read when I was learning, and I suspect that other slashdotters may concur. It is firmly pitched at the coder rather than the designer, takes you from CSS virgin to upper intermediate level, with good attention to the process of (re)designing with CSS, legal issues such as Accessibility (section 508), and assumes that you're not scared of mark-up." Lawson offers this disclosure: "I should immediately disclose that I've worked for two different companies that have published the author, Rachel Andrew, but I have no connection with the publishers, or this book." Read on for the rest of his review.
The CSS Anthology: 101 Essential Tips, Tricks & Hacks
author Rachel Andrew
pages 380
publisher SitePoint
rating 8
reviewer Bruce Lawson
ISBN 0957921888
summary Structured Q&A guide for CSS beginners

Author's credentials

Andrew is a long-term member of the Web Standards Project (WaSP) and programmer, technical project manager, technical team leader/senior developer and webmaster, according to her own bio.

Who's the book for?

The book's subtitle is somewhat misleading. There probably are 101 tips'n'tricks (I didn't count) but it's not the random miscellany that it implies. The information is structured so that a n00b could become proficient by reading the book from start to finish (I tested this out on a colleague). The tips'n'tricks structure does allow you to find what you're looking for in a hurry. The table of contents is easily scanned, and there is an excellent index.

The book doesn't offer advice on how to sex up the beauty of your site. That's fine for me; my current work involves replicating someone else's designs using xhtml and CSS, and as a coder I'm pathologically unable to design the type of showcases that you see at the CSS Zen Garden. A graphic designer might therefore find this book hard work; it jumps straight into a discussion of syntax, and there's occasional geek-directed statements (CSS supports multi-line C-style comments). Similarly, if you're completely new to html, this book probably isn't for you; there's lots of references to pre-CSS ways of working which could potentially be mystifying. Unusually for CSS books, there's a refreshing lack of polemic telling you why you should use style-sheets. If I read another history of the browser wars in a technical book, I shall scream.

So the book's constituency would seem to be those who know how to present information via html, and wish to take advantage of the smaller filesizes, greater flexibility and logical separation of the presentation layer from the mark-up that the (x)html/ CSS combination offers. The logical purity is my personal reason for moving to Web Standards; the trauma of writing text processing applications with VAX Fortran in the late '80s left me with the propensity to weep when I see html as sorely abused I mangled dear old Fortran.

Are you sitting comfortably? Then I'll begin.

Anthology kicks off in the conventional way for CSS books - controlling fonts and colours, styling hyperlinks, headings and the like. Each chunk is structured as a problem (How do I remove the indented left margin from a list?), a solution and sample code, and generally a discussion of related applications of the code, compatibility issues, accessibility notes etc. This is a pretty compact method of explication, and the basics of styling, syntax, pseudo-class order and the like are romped through in 40 pages, but not glossed over. The key to this is that Anthology assumes you know what you want to do, and shows you how to do it.

Chapter 4 (Navigation) is where the real meat begins - making navigation menus that are solely html unordered lists (because a menu is logically a list of links) and styling with CSS, adding rollover effects, styling navigation as buttons, changing the styling to a horizontal navbar, or even Amazon-style tabs without changing the mark-up. I suspect that, although these are techniques that can be found in most CSS books, the brevity and simplicity of the explanation will be revelatory to many. Chapter 5 (Tabular Data) may come as a surprise to those who mistakenly believe that web standards disallows the use of html tables, as it shows how to style tabular data - the examples are a spreadsheet and a calendar. Chapter 6 repeats the trick with that most mundane aspect of web development, the form.

Chapter 7 (Browser and Device Support) is about real-world CSS development. Unlike most books which instruct you to test in loads of browsers and leave it at that, this chapter lists all the main permutations of OS and browser (including tips on installing multiple versions of IE/ Win), and begins discussion of the tried and tested hacks to hide styles from Netscape 4, IE etc. All of this information is available on the web -- but for a newbie who isn't yet aware that it's possible to hide styles from certain browsers, it's a great way to introduce them to the murky practices of real-world CSS development. What's also refreshing in a computer book for n00bs is a discussion of how to seek help on lists and forums, with a guide to etiquette.

Chapter 8 (CSS Positioning and Layout) is where the stuff that stumps many a table-based designer begins. Along with fonts and colours etc, CSS can lay out the stuff on your page. I'm unsure about the success of this chapter; the Q&A structure is great if you're looking to build one of the sites that are explained (and the list is pretty comprehensive), but I came to the chapter hoping to cure a couple of bugs I'd found in a project I'd previously semi-successfully laid out with absolute positioning (A.P.).

Generally, I layout using floats as I also write the html, so it's easy to ensure that the markup spits out <div>s (sections) in the left-to-right, top-to-bottom order that I want to lay them out in. Suddenly, I had two projects that required A.P. for the first time, as it was not cost-effective to change the way that the client's CMS spat out the markup, so AP was required to position sections on the page regardless of where they appeared in the markup.

Anthology served me fine until I tested the page in IE and the layout was off. Nothing in the book gave me any pointers, and in the end I gave up Googling and just used a hack which exploits an IE parser bug to serve different co-ordinates to IE, after finding the hack co-ordinates through trial and error:

#APthing {position:absolute; top:34px; left: 758px; width:108px; height:88px;}
* html #APthing {position:absolute; top:19px; left: 785px;} /*for IE */

OK, so there may be a simple mistake I'm making -- but then, as far as absolute positioning goes, I'm the kind of newbie at whom this book is aimed, and I imagine that others will make the same mistake that I did. If the book had explained where I was going wrong, or given me the above hack, I'd've spent less time with Google and more time with Guinness.

Chapter 9 (Experimentation, Browser Specific CSS and Future Techniques) is successful, except for one small gripe. I'm glad that the author, although a member of the Web Standards Project, isn't an uber-purist. (I'm of the opinion that a little invalid code, if it's the only way to get the job done, isn't a hanging offense). So she shows how to implement IE-only proprietary CSS that can make colourful scrollbars, should you wish to do this. There's also a Mozilla-only CSS trick to allow curved edges to CSS boxes, which I implemented on my homepage that very evening.

However (here's the gripe), the most useful technique shown is one which allows fully-CSS flyout menus that don't rely on JavaScript. The author notes that it won't work for most people, as IE incorrectly restricts the hover pseudo-class to <a> tags only, while the CSS requires hovering over <li> elements.

Well, Yes and No. There's a well-documented and elegant hack which allows a proprietary Microsoft behaviour to be attached to the CSS that attaches a small JScript that corrects the IE bug, and thus allows this extremely useful CSS-only flyout menu to work in IE. I've used the technique myself when required to mimic the look and feel of a client's site while making it DDA/ADA accessible, and it works perfectly. To me, the omission of the IE hack from Anthology is an unfortunate oversight.

Summary

There's a couple of flaws in the book, though I suspect that in order to explain them, I've over-emphasised them. All in all, it's a solid, professional no-B.S. way for someone with a code-oriented mind to get them up to speed, satisfactorily and quickly; a motivated reader could be churning out standards-compliant, bandwidth-friendly sites after a few hour's experimentation. Ordering the book from the publisher's website was a good experience and, unusually, they have a money-back guarantee. As I said, I wish that I'd had access to Anthology when I was learning.


You can purchase The CSS Anthology: 101 Essential Tips, Tricks & Hacks 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 discussion has been archived. No new comments can be posted.

The CSS Anthology

Comments Filter:
  • by fiannaFailMan ( 702447 ) on Friday January 28, 2005 @06:55PM (#11509273) Journal
    as a coder I'm pathologically unable to design the type of showcases that you see at the CSS Zen Garden
    I wish people would get out of this mindset that you must be either a coder or an artist and never the twain shall meet. I work quite comfortably on both sides of that fence and I have met plenty of renaissance people in this industry who are just as comfortable with code as they are with a graphic design tool like Photoshop. It's that kind of thinking that leads to the most creative solutions IMHO. Back in the days of Leonardo DaVinci there was no Berlin Wall seperating technical and creative people, it's a relatively recent addition to our culture and a bit of an unhelpful one.
  • Re:CSS is annoying (Score:5, Insightful)

    by justMichael ( 606509 ) on Friday January 28, 2005 @07:17PM (#11509418) Homepage
    The problem with using a color name in your class definitions is about 2 minutes before the site is complete they decide all the blue stuff should be green and now you have blue that's really green.

    Name them for what they are, not what they look like. Somewhere down the road you'll be glad you did. ;)
  • Not sure who would plonk down good money when so many thorough tutorials are online.

    When you need to get things done FAST, and learn while not in front of your computer monitor, or maybe even have a quickreference handy, you need to buy books. Hey, what if suddenly your internet connection drops?

    I'm a customer of Sitepoint (the company that published the book), and I purchased the "build your own... website using PHP and MySQL". I keep it always handy on my job desk.

    Also, having a manual handy (either printed or downloaded, such as the PHP reference) saves you lots of trouble. I've talked with many people who just use the online PHP manual, and they keep asking me stupid questions they could have answered themselves had they downloaded the reference in CHM format.

    Never forget that time is money, and learning online "for free" might cost you lots of hours that you could have well spent designing a website and getting paid.
  • by fuw ( 823023 ) on Friday January 28, 2005 @07:25PM (#11509479) Homepage
    I don't know about that. Myself being more skilled in the programming area, I find I have a very difficult time creating a site that I would consider "professional looking". I mean, I love CSS and have jumped head first into creating CSS-based layouts several years ago. My problem however, is not having the "design eye" that gives folks the ability to create such beautiful designs that you often see in CSS Zen Garden.

    Sure, I *want* to create a well designed site, but until I get that knowledge (school) it just ain't going to happen (not for me, anyway).

    > I work quite comfortably on both sides of that fence

    It's easy to say that about yourself, sure I even would try to claim that one. But when I look at sites I have created and compare them to sites done by a *real* graphic designer (web designer), there *is* a huge difference.

    I'd consider myself a professional programmer and an amatuer designer at best.
  • by fiannaFailMan ( 702447 ) on Friday January 28, 2005 @07:48PM (#11509659) Journal
    I don't know about that. Myself being more skilled in the programming area.....
    I probably should have explained myself a bit better. The point of my original post was that there are people out there who make good designers and good coders at the same time, regardless of what you personally as an individual are good or bad at. It is possible.
  • Re:CSS is annoying (Score:3, Insightful)

    by Bitsy Boffin ( 110334 ) on Friday January 28, 2005 @08:31PM (#11509990) Homepage
    If you want variables, use a language designed to work with variables to dynamically generate CSS. You have plenty of choices: PHP, ASP, Perl, Parrot, etc. ad nauseum.

    Why introduce a whole new language into the mix if all you want to do is set some constants that can be used in your CSS.

    Things like
    darkcolor = black;
    lightcolor = green;
    so you can do
    .message { background-color: darkcolor; }
    .text { color: lightcolor; }
    obviously that is trivial, but there are a number of occasions I have come across where it would be useful, mainly with colors which you wish to remain consistent but use in different areas (you might want to use it as a background somewhere, and a border somewhere else, currently the only way to do that with plain-old-css is to hard code the color information in several different rules).

    It almost sounds like you actually LIKED <FONT> etc.
  • by warrax_666 ( 144623 ) on Saturday January 29, 2005 @05:24AM (#11512347)
    something along the lines of

    .foo { background-color: red; color: green; }
    .bar { inherits: .foo; color: blue}

    and that applying <div class="bar"> would then set the bgcolor to red and the fgcolor to blue. In your example you still have to remember that .bar is based on .foo in every single place you use it. Much less useful.
  • by fuw ( 823023 ) on Saturday January 29, 2005 @02:09PM (#11514345) Homepage
    Yeah, but 2/3 of those sites are built on table-based layouts (old school methods). If you're reading a CSS book or already know CSS (for creating layouts), then you're not doing table-based layout.

    Not to raise the hair on your back, but I wouldn't call any of those sites "good design". While they might be very usable and well-structured (not the markup), it doesn't take long to realize that they weren't created by somebody with a background in graphic design. Just compare to any of the sites in the CSS Vault [cssvault.com].

    Or if you want a similar theme, check out Red Hat [redhat.com] or Suse (Novell) [novell.com].

    I just took a closer look at the Open Source Web Design site, I like that idea. I can't help but think that they need to implement one of their templates on their own site.
  • by david.given ( 6740 ) <dg@cowlark.com> on Saturday January 29, 2005 @03:17PM (#11514770) Homepage Journal
    <div class="foo bar">

    I didn't know about that; useful, although not quite what I'm looking for. Ta.

    (The thing I object to here is that it requires the HTML content to have detailed knowledge of the mechanism of the markup, which is evil --- there's no need for the content to have to state that that particular div is a foo and a bar. It should just be able to state that it's a bar. The relationship to foo should be in the style sheet.)

    Big enough to fit what string? A container can fit any string with a proper overflow property.

    Big enough to fit a string without overflowing, of course.

    Take that hoary old example, the columned layout. On my website [cowlark.com] I have a columned layout made up of tables. I want the left-hand column to be as small as possible without wrapping the 'cowlark.com' logo in the top-left corner, and the right-hand column to occupy everything else.

    I cannot find a way of doing this with CVS. The problem is working out how wide to make the left-hand column. With tables, the logo does not contain any spaces, and so the table layout algorithm will try quite hard not to wrap it; try resizing the font and you see it all still works (pretty much). With CSS, I have to hard-code the logo's width, and I can't tell what that is, because it depends on the fonts being used.

    I have only recently discovered display:table-row and friends, and I could probably use those instead, but it's still basically tables. There should be a better way.

    CSS has lots of limitations (some of which will be addressed in V3, some of which aren't)

    <plaintively> Can we have decent support for CSS2, please? Leaving aside the aberration that is IE's attempt at CSS implementation, Gecko doesn't even do counters yet...

All seems condemned in the long run to approximate a state akin to Gaussian noise. -- James Martin

Working...