I got this question the other day. My first thought is: weird question! Specificity is about selectors, and at-rules are not selectors, so... irrelevant? To prove that, we can use the same selector inside and outside of an at-rule and see if it seems to affect specificity.
The background is black. But... is that because the media query increases the specificity? Let's switch them around.
The background is red, so nope. The red background wins here just because it is later in the stylesheet. The media query does not affect specificity. If it feels like selectors are increasing specificity and overriding other styles with the same selector, it's likely just because it comes later in the stylesheet. Still, the See this tiny example:
You'd think the background would be red, especially with the The post How much specificity do @rules have, like @keyframes and @media? appeared first on CSS-Tricks. from CSS-Tricks https://css-tricks.com/how-much-specificity-do-rules-have-like-keyframes-and-media/ The post How much specificity do @rules have, like @keyframes and @media? is republished from The Instant Web Site Tools Blog from https://www.instant-web-site-tools.com/2019/07/31/how-much-specificity-do-rules-have-like-keyframes-and-media/
0 Comments
Leave a Reply. |