This Thanksgiving I've decided it's about time that I provided some more background and analysis on one of the things I am certainly unintentionally (in)famous for. This entry was started at 7pm on Thanksgiving evening, but took me until now to complete.
I don't know who first came up with using the presence of a 'media
' attribute on <link>
or <style>
to hide CSS from Netscape 4, but it was the first technique that I remember hearing of to use a perfectly reasonable HTML feature (yes, the 'media' attribute is in HTML, not CSS) to deliver CSS selectively to browsers that supported a certain feature.
This HTML-based "filter" was perhaps the first such technique, though it would be many years before the term "filter" was introduced as a general term for such techniques.
The first filter I came up with (again, before they were named as such) was perhaps the @import with quotes filter, which I didn't even bother writing a page about in particular because it seemed so simple: @import "foo.css"; is only supported by IE5, NS6, Opera3 and better. I just posted an example usage at the time for Web Standards Project's Browser Upgrade Campaign (BUC). That particular legacy contribution was also made anonymously to one of the ALA redesigns, though I believe Jeffrey has outed me at some point since.
Neither the HTML 'media' attrribute filter nor the CSS @import quotes filter, in my humble opinion, qualified as hacks, because they lacked what some might term the essence of a hack:
either a kludge, or the opposite of a kludge, as in a clever or elegant solution to a difficult problem
. Neither of those filters were particularly kludgy (warning, not a Scrabble word), nor clever. In other words they were too "obvious" to really be considered hacks.
Anyway, the @import filter seemed harmless enough. At the time the only big difference it made was to filter out IE4.x (both Mac and Windows), which had already been obsoleted by IE5 (both versions). And it was praised as: ... for people who make websites, that is nothing short of revolutionary.
Sidenote: note the fact that that article on ditching <table>s for layout is almost FIVE years old
yet those of us that are real professionals still have to repeat the message .
Thus the idea of using a feature of CSS to essentially do a lightweight form of browser specific style sheet switching was born, but the Pandora's Box (Model) of CSS Hacks had yet to be opened. That would come exactly one week later.
Jeffrey Zeldman expressed to me how nice it was that it was possible to write CSS without having to worry about what might look bad in (or even crash) obsolete browsers like Netscape 4. Having been freed to use more of (and depend more on) CSS, he and many others following A List Apart's suggestions quickly ran into the next issue which was the inconsistent box model treatment between IE5.x/Windows and IE6/Windows.
If only there were a way to send one width to IE5.x/Windows, and another width to modern browsers which supported the CSS box model...
is a rough approximation of what Jeffrey said (emailed) to me at the time.
Eager to be helpful, and armed with the intuitive knowledge that the key to Pandora's Box of CSS hacks could be hidden amongst the jungle of CSS1 section 7.1 parsing tests, I went hunting. It didn't take long until (with Todd Fahrner's help) I discovered how test twentyb (rotation-code: "\"}\"";
— look familiar?) messed up all versions of IE5.x/Windows,
but no other modern browser. After that it was a simple manner of finding an abandoned CSS2 property which accepted arbitrary string values.
I had opened Pandora's Box (Model) of CSS Hacks, and there was no turning back.
Shortly thereafter, I generalized the Box Model Hack to enable hiding entire style sheets from IE5.x/Windows and CSS Filters were born. More followed soon thereafter.
Implicit in the story above are a set of design principles which I kept in mind when I first set about creating CSS hacks, and which I really should have noted at the time. Given all the hand-wringing about CSS hacks incited by my colleague Markus Mielke, it's about time I documented these principles. More on the hang-wringing later.
But I didn't document those principles at the time. Once said Pandora's Box was opened, it didn't take long for the notion that hacking CSS was a "good idea" to spread far and wide in the web design and development community (much further than I could have possibly expected, to the #4 result for 'hack' on Google, and even onto t-shirts!). Of course once hacks for IE5.x/Windows had been discovered, and refined into the concept of "filtering" which browsers got to see whole style sheets, it was only a matter of time before hacks were developed and documented for nearly every browser. Nevermind that so many of the hacks violated the above-mentioned principles. Those ideas spread and mutated without any such strings attached.
At this point I can only strongly recommend that people evaluate these myriad hacks based on the above principles before using them.
Now, about that inciting and hand-wringing that took place last month.
The irony is that I don't disagree with the details of Marcus's MSDN post. Note that his "Call to action: Please check your pages" does not mention a single one of the CSS hacks I developed. The one partial overlap is the use of the child ">" selector, which was introduced as part of the Box Model Hack to "Be Nice To Opera" (Opera 5 in particular, which at this point is probably ignorable — anyone even hear of anyone that still uses Opera 5, even for testing purposes?).
The sad thing is that most of the hand-wringing could have been avoided (as noted in the comments) if people would first try fully standards based cross-browser solutions before resorting to hacks.
However, the undertone of that blog post (and what Markus and Chris Wilson have expressed to me and others in person) is that web developers must stop using CSS hacks altogether.
I know that's perhaps a bit of a hyperbole, but that's the message that's been heard nonetheless. However, such a message is, with all due respect, the impractical perspective of folks who are not a professional web designers / developers. I know this, I was there once too.
To be specific, the problems with hacks have arisen because of hacks that are targeted at a current browser, namely, IE6/Windows. E.g.
* html
And a misperception that the use of an implemented feature is a hack.
E.g. people (ahem, starting with the "BMH" as noted) have used the child selector to send "valid CSS" to "compliant implementations", e.g. with
html>body
That's not a hack. It's not targeting a specific browser. It's actually inclusive of all browsers who would support CSS2(.1) selectors.
Sending valid CSS to compliant implementations is proper behavior.
(With apologies to Star Trek)
Does this make it harder for new/late implementations (like IE7) to come along and support that selector?
Why yes it does. This is no surprise.
If you support the child selector, now all of a sudden you have to compliantly support all the other properties/values of CSS2(.1) that authors have been successfully using with the child selector.
But given that several other browsers do so (otherwise authors wouldn't be using the child selector), and thus the market has demonstrated this is not a problem, this is a reasonable expectation.
However, if a browser is somehow unable to do so, then the answer is simple.
Don't implement that selector, until that browser is able to do so. IE5/Mac did so, so can IE7, more than five years later...
This may seem "unfair" that that these features (a CSS2(.1) selector and some CSS2(.1) properties/values) are now "tied" together in terms of requiring implementation support, but guess what?
CSS2(.1) doesn't say you can implement part of the spec. You're supposed to implement the whole spec in the first place.
Obviously this was hard (in fact, impossible for self-contradicting and ambiguously written REC-CSS2 in 1998), and browser vendors (yours truly included) tried to do the next best thing, which is to implement logical "chunks" of CSS2(.1).
Well it's been 7 years since REC-CSS2, and those logical "chunks" have simply grown, more, chunky, as it were. They've also been clarified down to previously unseen levels of details in CSS2.1
You need to keep coding just to keep up.
The bottom line: eventually what will happen (within a couple of years at most?) is that so many browsers will have implemented all of CSS2.1, and authors will be writing with that in mind, that any new browser that wants to support part of CSS2.1 will have to support all of it in order to support the style sheets in the wild.
IMHO, that's called progress.
But we don't have any fully compliant CSS 2.1 browsers yet. And we still have obsolete/abandoned browsers with enough marketshare (or machine dependence) to warrant the incremental bit of effort to support them. So for now:
<legend>
in IE6/Windows), and specify that styling explicitly instead of depending on the defaults.
If you've made it this far, you've been extraordinarily patient and have the attention span of a savant. I wish you a happy Thanksgiving holiday.
Also blogged at Webstandards.org
I related some recent no fun experiences to my friend and co-worker Derek, in particular experiences relating to trying to be helpful, and then being taking advantage of, or having stuff neglected, or just being treated like I didn't matter, which was very odd, since I was the one providing help! I don't want to get into the details because frankly I don't wish to dwell on them.
Suffice it to say, Derek pointed me to his friend John's (who I happen to know as well) post on "Optimism Tax". Go read the whole thing.
My loss in this recent case was more emotional than financial (though I probably have about a couple of hundred dollars worth of stained pillows and blankets which might be treatable, as if I have the time to deal with that).
But regardless, John's philosophy still makes a lot of sense, and is something that I am learning to accept and embrace because it makes a lot of sense to me.
If you're nice to people, and help them out, sometimes you're going to get taken advantage of and lose some time, or some stuff. Hopefully you won't lose a friend, but sometimes that can happen as well.
I'll also consider the loss of time and stuff to be part of my optimism tax. I'll accept that from time to time I will have to pay this fee in exchange for optimistic freedom.
I prefer to pay this tax, and remain optimistic about people, and the world, rather than be focused on the negatives.
As John says: the cost to my quality of life (by worrying more) is far more expensive than the cost of losing some stuff.
Suffice it to say it's been a rough couple of weeks and more, continuing on where Halloween left off. But in addition to dwelling on some of the crap I've had to deal with so far this month, I'm going to mention a few positive highlights.
Well that's still more fun things than no fun things. I guess part of it just how busy the month has been so far, and that's not even counting the meetings, events, tasks etc. omitted from the above list. Another part of it is perhaps the fact that the no fun things have so far overshadowed the fun things even if they didn't outnumber them.
Our weekend in LA was warm and pleasant. That Saturday was packed. My parents took Amber and I to the special "Tutankhamun & Golden Age of Pharaohs" exhibit (9am "showing" - ouch!) at the Los Angeles County Museum of Art (LACMA). Having enjoyed far too many science fiction movies and TV shows which have borrowed liberally from Egyptian history and mythology (Ahem. Battlestar Galactic (original), Stargate, Stargate SG1, The Mummy, The Mummy Returns, The Scorpion King), it was nice to get some of the real background, and see artifacts 1000s of years old in person. Amazing.
We had lunch afterwards in the Plaza Cafe, a nice cafeteria style restaurant next to the museuem bookstore. Since the special King Tut tickets got us into the rest of the museum, we checked out the special Mayan exhibit as well. It was quite interesting to see the artifacts of two different very old cultures that lasted for many hundreds of years, each becoming an artifact of history themselves.
Taking advantage of the warm sunny weather, we drove to Newport Beach, set out a blanket, chairs, and played a new card game called Quiddler which was a lot of fun. Unable to resist the water I jumped in while everybody else looked at me like I was crazy. Dried off, changed out of my new swim trunks, and stopped across the street at the Crab Cooker for Manhattan clam chowder, smoked salmon, and tartar sauce wrapped up to go. Those plus all the other goodies mom had cooked made for quite a feast when we got home.
Sunday was a day for sleeping in, and going shopping with Amber at all my classic hometown spots: Some Crust Bakery and Rhino Records in downtown Claremont, and of course the various stores at Montclair Plaza, the local two story indoor mall.
Returned home that evening to a load of stressful things, personal, professional, situational etc.
The one pleasant exception being the success of TagCamp, including the surprise last minute deployment of the hCard Kwiki plugin by SocialText's Casey West and Brian "Ingy" Ingerson. Check out the TagCamp ContactList which automatically aggregates all the hCards across the entire TagCamp wiki. In one fell swoop the SocialText guys have demonstrated that microformats work well for structured wikis (in addition to structured blogs). Well done Casey and Ingy!
Now that SocialText has raised the bar for structured wikis with their support of the hCard microformat in the Kwiki platform, I'll make the call official.
MediaWiki, MoinMoin, and all other open source wikis: let's see plugins, additions, patches etc. for hCard, hCalendar, and hReview to start with. Go copy liberally from the Creative Commons attribution (by-2.0) licensed hCard creator, hCalendar creator, and hReview creator. Let's see what you can do!
The weeks leading up to Halloween I was far too busy and preoccupied with many too many annoying time-wasting things, so never had the time to prepare anything for Halloween itself, neither costume, nor candy, nor party. So I spent the evening barely finishing up a yawner of an obligatory weekly status report before falling unconsciously asleep. A waste of a perfectly good Halloween, which is truly sad, as it's probably the biggest holiday in San Francisco.