Are CSS child selectors a W3C standard?

237 views Asked by At

Child selectors like this:

#id > a 
{
  background-color: blue;
}

Doesn't seem to be referenced on the w3schools css website. Is it bad practice?

4

There are 4 answers

0
Pekka On BEST ANSWER

Is it bad practice?

No, but it is not supported by IE6, which still is kind of a limitation for some sites.

0
justkt On

Yes, child selects are part of the standard as seen here for CSS2.

1
Michael Irigoyen On

To answer your question, child selectors are not bad practice and can be very useful is certain situations. They are also in the CSS 2 standard. They are not supported by older browsers (IE6), but all modern browsers can use them.

As a side note: W3Schools is not affiliated in any way with the W3C. If you want more detailed information on the actual standards, you should go directly to the W3C's website.

0
Hawxby On

Yes, they're in the standard.

http://www.w3.org/TR/CSS21/selector.html#child-selectors

As mentioned they don't work on IE6 though. If you can grab metrics from your site and determine if the proportion of IE6 users is worth the extra development effort. If not try and define your user base to make a rough guess as to the browsers they're likely to use. Failing that, try make it fall back in a vaguely graceful way so at the very least the site is still usable even if it doesn't look quite as good as you would like.