
YAWEI 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
Pro 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.