开发者

Are CSS child selectors a W3C standard?

开发者 https://www.devze.com 2023-02-07 20:38 出处:网络
Child selectors like this: #id > a { background-color: blue; } Doesn\'t seem to be referenced on开发者_StackOverflow社区 the w3schools css website. Is it bad practice?

Child selectors like this:

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

Doesn't seem to be referenced on开发者_StackOverflow社区 the w3schools css website. Is it bad practice?


Is it bad practice?

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


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.


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


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号