CSS Pseudo Selectors [closed]
I was just curious as to what CSS Pseudo selectors everyone thinks are safe to use. I am asking because there are so many great specifications and recommendations that were done by W3C, however a lot of them are not supported by IE8 (no surprise). Even some of the pseudo selectors specified as per CSS2.1 do not work properly in IE8.
To bring it to the point, I just would like to know what everyone is using and considers safe to use for maximum cross browser compatibility (so works in IE8, FF3.5+, Chrome). I am asking because I want to make a quick list of things that I am not using currently that perhaps I should be using when styling pages.
Anyhow, I hope you guys can point me in the right directions.
NOTE: I would like pure CSS suggestions. I am NOT interested in including some third party javascript library to fix bugs for me. Just things that work straight out of the box.
Consider for example, the :after pseudo selector. It is co开发者_如何学Cmpatible according to the charts that have been linked numerous times, however when you try to clear a float as per the following code it does not work:
.clear:after {
content: ".";
height: 0px;
display: block;
clear: both;
visibility: hidden;
}
Were you looking for this? http://kimblim.dk/css-tests/selectors/
The list shows that CSS1 and CSS2.1 pseudo selectors are supported by IE8. Perhaps you are referring to IE7?
Check your project's spec on which browsers need to be supported.
Check which selectors and features you can use in those browsers (Compatibility charts on Quirksmode for example). If you decide on using something that not all of them supports, create a fallback plan or find a workaround.
Since 'looking identical' is not a requirement, all of them are safe if you plan for what will happen when they don't apply.
This is probably going to be the most accurate and most up-to-date list that you'll ever get: Wikipedia. As already mentioned, looking identical is not required, but as far as compatibility goes there's a lot of differences between browsers (especially with IE8 thrown into the mix).
精彩评论