CSS CSS Layout Basics Getting Started with CSS Layout Why Vertical Margins Collapse

Arikaturika Tumojenko
Arikaturika Tumojenko
8,897 Points

Different selectors to style h1. Any reason for that?

I've noticed Guil styled the h1 inside the header two times, first using the h1 selector and after using the .name class. Why is that?

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The difference isn't really noticeable in this particular example. But imagine for a minute that you had multiple h1 elements on your page with top margins. By specifying the class to be used, you can ensure that only the h1 elements in that class will be affected by your rule instead of all h1 elements on the page. :sparkles:

Arikaturika Tumojenko
Arikaturika Tumojenko
8,897 Points

Ok, thank you. I was wondering for this example :).

Nice answer Jennifer Nordell.