css - Why do I need *, *:after {...} instead of just * {...}? -
Can anyone explain why the universal selector does not apply to it? A relevant part of the standard would be great, but there would be logic behind it too.
Edit : I can see that my question is a bad word; I'm sorry. I mean that * {color: green; }
A document makes all the text in green very much, but does not apply to it, #mypar: after {content: "newly-added content"; }
. I know that this content is not present in the original dome ... but it seems that * {color: green; }
instead of having to type *, *: after {color: green; }
.
I have also edited the title of my question for clarity.
Edit 2 : This is bad ... OK, I tried to provide a simple example and did not help. After reading my question came note that the author's use
*, *: before, *: after {-moz-box-sizing: border-box; -WebKit-box-size: border-box; Box-size: border-box; }
instead of
* {-moz-box-sizing: border-box; -WebKit-box-size: border-box; Box-size: border-box; }
universal selector *
matches any element , But are not considered as pseudo-element elements, they can be selected only by a selector who uses the pseudo element selector such as : after
.
In the case given in the question, the pseudo element will still be green when * {color: green; }
is used and no rule overrides it even if no pseudo element matches *
, the actual element associated with it matches, and Color
might have inherited from it but if you tried * {boundary: solid 1 px}
, then you will see that all elements have limitations, but there are no pseudo elements ( border
property is not inherited)
I do not think that There is no official reason for this, but it does not seem that in cases of use where the pseudo elements must match the universal selector.
Comments
Post a Comment