r/csshelp • u/GoPotato • Jun 07 '20
Why does a pseudo element selector override inline styling?
Everything I read about precedence and specificity says that inline styling overrides all selectors, including pseudo element selectors. In MDN it says that an inline style is assigned a value of 1000, while a pseudo element selector is assigned a value of 1.
This is a snippet of the code in codepen.
<style>
p::first-letter{
color:green;
}
</style>
<body>
<p style="color:blue">Hello World!</p>
</body>As you can see the first letter is colored green overriding the blue one set by the inline styling.
10
Upvotes