Are CSS child selectors a W3C standard?

守給你的承諾、 提交于 2019-12-25 06:36:32

问题


Child selectors like this:

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

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


回答1:


Is it bad practice?

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




回答2:


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.




回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/4831134/are-css-child-selectors-a-w3c-standard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!