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

Erick Martinez
Erick Martinez
2,894 Points

I had to get rid of margin: 0.67em 0; in normalize.css in to get rid of the top margin in h1

Full disclosure: I don't use the workspace. I use Atom script editor and host via Netlify. I don't that should matter tho, right?

I notice the top-margin of h1 wouldn't go away even if I set the style.css h1 to "0". So I open chrome dev tool and noticed the "0" margin in style.css (I did like the video) was crossed out and instead it was displaying the margin: 0.67em 0; from normalize.css stylesheet.

Any idea why guy/gals?

4 Answers

What order are the stylesheets being loaded?

Erick Martinez
Erick Martinez
2,894 Points
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="normalize.css"/>

The last takes precedence. So normalize.css will override style.css

Erick Martinez
Erick Martinez
2,894 Points

Thank you very much. I just changed it and you are right! Thank you very much!