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


Wen Ze Lee
Wen Ze Lee
4,209 Points

Why can't some properties be inherited? What are the types of properties which cannot be inherited?

In my css, I set

body{ margin: 0; }

and I realise that my h1 and h2 did not inherit the margin properties. What is the reason?

Thanks for any help!

1 Answer

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points


I don't know the exact nature of specificity but in the cascade, certain rules override each other.

On your body tag, what you've done as set what's called an author style, a style set up on the page or an external style.

But when browsers render certain elements, they give those elements default styling known as Browser styles. Without seeing the whole page I can't be sure why the headings aren't inheriting the margin but it sounds like the browser styles are taking precedence on your heading elements. :-)