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 trial

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,638 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,177 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