13.02.2013 Views

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

56<br />

As with our IE5/Mac-specific CSS file, these two @import<br />

rules bring in external style sheets that patch bugs in different<br />

versions of IE/Windows: the first is for all versions of<br />

Internet Explorer on Windows, and the second is seen only<br />

by IE5/Windows. Even better, every other non-IE browser on<br />

the planet is oblivious to these browser-specific workarounds,<br />

since these conditional comments are seen as regular<br />

HTML comments by standards-compliant browsers. As<br />

a result, the link to patches-ie.css is essentially invisible to<br />

most browsers and handily parsed by IE/Windows.<br />

At this point, you’re likely wondering (read: “screaming<br />

furiously at the ceiling”) why you should bother to fork<br />

your CSS like this. Why link to two separate style sheets,<br />

which only exist to @import other CSS files, some of which<br />

are filled with nothing but workarounds for different<br />

browser-specific CSS bugs? (See Figure 3-3.)<br />

As you might be aware, you have any number of ways to<br />

insert browser-specific CSS patches alongside your other<br />

Figure 3-3. Our CSS architecture<br />

CSS rules (see http://cssdiscuss.incutio.com/?page=<br />

CssHack for a few examples). While keeping your CSS all<br />

in one file only leaves you one CSS file to worry about,<br />

tracking down and updating fixes for individual browsers<br />

can quickly become a nightmare. With the multiple style<br />

sheets approach, you can intelligently quarantine CSS<br />

patches into browser-specific style sheets, which will<br />

make future updates a breeze. And what happens when<br />

you stop supporting a browser? Well, instead of searching<br />

through more than 2,000 lines of a style sheet for every<br />

IE5/Mac hack you wrote into your main CSS file, you can<br />

simply delete the @import reference to that browser’s<br />

CSS patches in one of the linked style sheets. ’Nuff said.<br />

With this hack management framework in place, we can<br />

now start in on the interesting stuff: applying some basic<br />

style to our document’s markup. Yes, I realize that it’s<br />

about darn time.<br />

The approach outlined here was inspired by Molly Holzschlag’s excellent article, “Integrated Web<br />

Design: Strategies for Long-Term CSS Hack Management” (www.informit.com/articles/article.<br />

asp?p=170511&rl=1). Written nearly two years ago, the article reads as well today as it did when it was first<br />

published. Read it, bookmark it, rinse, repeat.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!