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 Basics (2014) Fundamental Concepts Inheritance

Ricky Simpson
Ricky Simpson
4,652 Points

color: black; vs color: initial;

What are the benefits / reasons to use color: initial instead of color: black?

Thank You Ricky

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Ricky,

From what I remember (it's been a bit), the initial value and "Black" will not necessarily be one and the same. The initial value will come from the parent element and is dependent on where or not an inherited value is specified.

So "initial" could be a color previously specified for the parent, or it could be "black" if there was no value previously specified. It doesn't really shed that much light on it, but here is the MDN Doc.

:dizzy:

Callum Anderson
Callum Anderson
8,837 Points

I can't find a definitive answer for this at all, I tried setting the html element to red, the body element to blue, and two further nested div elements to green and orange respectively.

Setting the deepest nested div color to initial makes it black.

I can only conclude that initial sets the color back to the default colour if no style had been applied. So, yes, it will always be black (unless the browser default isn't black).