on-internet
← Community

CSS specificity not as expected in my nested CSS

Stack Overflow ·

I have a bunch of CSS structured as such: body { > header, > nav, > main section, > main form, > footer, > small { > div { padding:3.2rem 2.6rem; @media screen and (min-width: 750px) { padding:4rem; } } } > header { > div { @media screen and (min-width: 750px) { padding-top: 2rem; padding-bottom: 2rem; } } } } Which I would expect to have sections of my page with 4rem paddings except for my header which I'd expect to have top & bottom padding of 2rem. This hasn't been the case for some reason - the header has 4rem of padding on each side. I've simplified my CSS here for readability.

Comments

Sign in or sign up to comment and upvote.

No comments yet.