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

Aakash Srivastav
seal-mask
.a{fill-rule:evenodd;}techdegree
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,617 Points

h1 default margin

While inspecting in "Chrome Dev tools" , when i hover over the "li" items , i saw only blue color there i,e contents only but i hover over the h1 element , i saw blue and light orange both colors i,e contents and margin both...why? Please explain , I want to master this concept.

2 Answers

Max Senden
Max Senden
23,138 Points

Hi Aakash,

Each browser has its own default styling for HTML elements. It's called the 'user agent stylesheet'. You'll learn about it in detail, and how to "reset it", if you keep following the course. In this particular case the top margin of the H1 pushes down the content box, thus creating the whitespace.

Hope it helps! Max