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 CSS Basics (2014) Getting Started with CSS Importing Style Sheets with @import

George Chatzispiros
George Chatzispiros
2,912 Points

What about conflicts between linked css files and imported ones with duplicated styles and classes?

e.g. same body style but different values to each style

2 Answers

Steven Parker
Steven Parker
231,236 Points

Because of the cascading nature of style sheets (the "C" in "CSS"), whichever rule comes last will take precedence over other rules of the same or lower specificity.

And a rule with higher specificity will take precedence no matter which order it is loaded.

Steven Parker
Steven Parker
231,236 Points

Specificity is determined by the number and type of identifiers in the selector. For example, a class name is considered more specific than a tag name, and an ID is more specific than a class name. And two of the same type is more specific than one of that type.

For more details, see this MDN page on Specificity.

George Chatzispiros
George Chatzispiros
2,912 Points

Thanks a lot for your fast response!