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 trialVirginia Ceban
1,510 Pointswhat will happen if an element have 2 classes and they have the same properties, what then overrides?
I saw that if an element have a class and a id, and in there is the same property, the id property overrides the class... but what happen if an element have 2 classes and they have the same properties, what then overrides?
2 Answers
Stephanie van Doleweerd
3,075 PointsJust to be pedantic; this is because CSS stands for "cascading" style sheet - the instructions cascade from the top of the CSS file to the bottom, and the instructions at the bottom of the cascade will take priority.
Virginia Ceban
1,510 PointsThanks!
J S
7,387 PointsJ S
7,387 PointsHey Virginia,
I believe it's whatever class is declared last in your CSS will take precedence. For example, in my code snippet below, the style in the "second" class will override "first" (no matter what order you put them in the HTML).