Thursday, November 1, 2007

CSS Paradox

This post will only tickle web developers with the kind of interest in cross-browser Cascading Stylesheet hacks that I tend to exhibit, so people who have no idea what CSS means, go away now and wait for a new post.

During work today, one of my trainees managed to do something that actually delighted me: he made a quirky mistake that was so logical and weird at the same time that I really needed to share this with the rest of the group to see if people understood the contradiction in terms. I then shared it with my colleagues, peers and friends. I might as well post it on my Blag and share it with the world:


* html>body { margin: 0; }


This is a wonderful combination of hacks and theoretically solid logic that will never, ever work, unless somebody will deliberately introduce a bug into an opensource browser to "get" this.

The poor guy seemed embarrassed when I showed this to people, but I honestly love this utterly logical, yet impossible declaration in CSS. He made my day with this one. I ought to name the paradox after him.

Labels: , ,

2 Comments:

Blogger Unknown said...

As I'm not as well versed in css... more on the adoption of the design department later (well, ok, basically: I've forced them to HAVE to adopt css, and properly done CSS) (I'm sorry, we can't do tables. Nope. Can't. Some of the phones don't support tables. They do css, though.)

Anyway, does > have a function in CSS?

I've managed a bit of fun hackery using the :before and :after bits (you'll need to pardon me if that's not quite correct, but I believe it is - same as :hover, with the colon) which introduced the capability of, well, an if statement (:

Basically, css is all if statements. Just none are written. But it's all a big if. Or a case statement.

Anyway. Got me a conditional in there.

Um, yes the question was about > ... is that legal?

December 6, 2007 at 9:06 PM  
Blogger Hung Laxley said...

Yes, child selectors are perfectly legal. However, what he's doing is simply impossible -the * html part is something that only IE6 (and worse) can parse. However, IE below version 7 does not support child selectors, so the whole thing is going nowhere at all.

(Maybe Mac 5.2 for OSX has * html support, but quite honestly, that was never part of the programme)

December 21, 2007 at 10:05 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home