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

HTML

christian lian huat toh
christian lian huat toh
7,213 Points

block level elements

Why some block level elements by default doesn't have a default margin like <article></article>, <aside></aside>, <div></div> and etc.

while there are some that have a default margin like <p></p> and <h1></h1> tags. whyy ?? :'(

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

A lot of this depends on the defaut margins that the user agent i.e. the browser has applied. But you can easily control this with CSS.

You can use your browsers development tools to see exactly how much margin and padding has been applied to each element on your page. If you use Google chrome you can access Chrome DevTools with Ctrl/CMD + j

To make sure that you have a level playing field throughout your project you can apply a CSS reset style to your project. Doing this will give you peace of mind as to how margins and padding are applied to your elements by default.

christian lian huat toh
christian lian huat toh
7,213 Points

Thank you very much sir! :) I was really curious about why block level elements had different margins, but now i know that it depends upon the user agent :)