On this MS compatibility table it says, IE9 does not support pseudo-elements ::before
and ::after
, but when I try it seems it does... see JSBin
Am I doing something wrong? I thought ::before
and ::after
would be nice tools to hide stuff from IE9, when in fact, they don't.
The CSS2 pseudo-elements :before
and :after
, with the traditional single-colon notation, are supported by IE8 and later. They are not new to CSS3.
The double-colon notation, on the other hand, is new to CSS3. IE9 does support this new notation for ::before
and ::after
, and likewise for the CSS1 pseudo-elements ::first-line
and ::first-letter
. Going forward, however, no new pseudo-element may use the single colon syntax, and browsers (including IE) are expected to support the double colon syntax for all pseudo-elements.
I have no clue why that table says IE9 doesn't support the new pseudo-element syntax, because it certainly does according to the docs for the individual selectors linked above, and your test case. As well as, of course, this answer.
IE 9 supports the notations ::after
and ::before
(with two colons) in “standards mode”. In “quirks mode”, it does not. This can be tested e.g. as follows:
<style>
p::after {
content: "***AFTER***";
}
</style>
<p>Hello world
Here the CSS rule is ignored, because IE 9 goes to quirks mode. But if you add the following line at the very start, IE 9 goes to standards mode and the CSS rule takes effect:
<!doctype html>
It is common in IE 9 that in quirks mode, new CSS features (most features that are neither in CSS 2.1 or in the IE legacy) are not supported. In quirks mode, IE 9 does not support the old one-colon notations :after
and :before
either. It supports them (but not the two-colon versions) in “IE 8 mode”, which you can select in developer tools (F12) manually, in the “document mode” menu, or at document level using the tag <meta http-equiv="X-UA-Compatible" content="IE=8">
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With