Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Do media queries have the greatest specificity on a CSS stylesheet?

.

3 Answers

Steven Parker
Steven Parker
229,582 Points

Media queries are customarily located last in the CSS, so the rules in them override any rules above them with the same specificity because of source order.

The media query itself doesn't have a specificity, but the rules inside it each have their own.

.

Steven Parker
Steven Parker
229,582 Points

I amended my answer to clarify that the rules have the specificity, which is based on their selectors.

.

Steven Parker
Steven Parker
229,582 Points

That's why I said the rules in the media query "override any rules above them with the same specificity".