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 trialDanielle Massey
Courses Plus Student 353 PointsWhy do you override code in .css instead of deleting it?
I noticed that in CSS, when you want to override a code, you write a different code under it so that the browsers follows that rule that come last. But my question is, why don't we just delete the rule that we do not want to use rather than writing another one beneath it that overrides it?
2 Answers
Douglas Miles
2,193 PointsGood question, I think it has more to do with when you get into complex things like multiple selectors, and media query's. Also when you start using multiple css files it is better to overwrite a property than it is to find what property has specificity than deleting it. Or when you take normalize.css or something that someone else coded, you don't really want to change their code so you override it, and css gives us that choice. Just realize their is a reason for it and as you learn more about css it will make more sense. (hope this helps)
here is an article by smashing magazine that explains spacificity. http://www.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/
Danielle Massey
Courses Plus Student 353 PointsThank you so much for your feedback! That makes perfect sense and I can see how that would shorten the coding time and make web design more efficient!
Douglas Miles
2,193 Pointsyour welcome, just wait until you start using sass or less to write your css.. talk about making it more efficient. =)