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 trialYAWEI SONG
9,168 PointsWhy can't I copy "border-top: 2px solid lightgrey" to "primary-content" and "footer"? Why should I create a new class?
Why can't I copy "border-top: 2px solid lightgrey" to "primary-content" and "footer"? Why should I create a new class?
2 Answers
jared eiseman
29,023 PointsThe short answer would be re-usability. If you ever want to give another element that same top border, all you have to do is add the class to the html element, bing bang boom, done. Just good practice, not a requirement. You can totally do what you suggested, just might make things simpler in the future if you have it separated out.
Ada N
Courses Plus Student 4,246 PointsHi Yawei, I second what Jared said. You'll be repeating a lot of the same css code over and over again when you don't have to. It's far easier to add the same class name to elements in your html. :)
Szymon Madeja
707 PointsSzymon Madeja
707 PointsDoesn't this break the separation of structure and presentation, though? Shouldn't classes be semantic and define what elements are, rather than what they should look like? If we create classes that are only used to apply certain styles, we're moving presentation back into HTML. I don't think it's good practice.