CSS selectors

by Juliet Kemp

I am in the process of rewriting the work website to be all CSS-shiny, standards compliant, easy to update, all that jazz. During which I have been led to really wish that CSS had a "has child" selector. It is of course possible to fake it, but you have to do it in the markup (by using a "has-child" class) which is suboptimal. Thankfully it's the navigation that needs this, for which I use server-side includes, so I only have to do it in one place; but it makes my nice tidy markup messy!

I went looking for whether CSS3 would feature this. Nothing on the CSS3 Roadmap (2001? Blimey, that's old.) It does though mention that selectors will be extended. However, the most recent CSS3 selector document doesn't give has-child as one of the selector extensions. So I guess that's a no. A shame.

In other news: LinuxChix button
Any Linux-using women out there who aren't already aware of LinuxChix? Click and find out!


2008-02-21 08:51:00
You probably wouldn't want to be relying on anything in CSS3 being implemented any time soon anyway...
Carla Schroder
2008-02-21 12:09:44
Linuxchix rocks! We are fun and geeky and mostly pleasant!

You kids and your fancy CSS. In my day, all you needed to know was how to build huge complex nested tables, and not to use the blink tag.

Michael Johnson
2008-02-25 11:48:04
I believe the :empty selector does what you want, except inverted. IIUC, this is supported in Fx 2.0+, Opera 9.5, Safari 2.0+, and Konqueror 3.5.4+. Maybe IE8?
Juliet Kemp
2008-02-26 04:41:40
I so much prefer CSS to tables... much easier to read!

Martin: thank you! That hadn't occurred to me - I'll give it a go.