Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
color: initial; vs color:black;
In the video https://teamtreehouse.com/library/css-basics/fundamental-concepts/inheritance, Guil is talks about inheritance. He states that you can tell the browser to ignore inheritance with color: initial. In this particular scenario, it sets the color to black, if you want the text to appear black why would you opt for color: initial; over color: black; in this particular scenario?
(likewise, why would you use color: initial; over color: [hex/rgb/color name]; if the desired color is the same?)
I cannot see it being used in this particular scenario (or many at all) as it does not save multiple lines of code, they are both simply one line, which leads me to the question, is it based on preference?.
Could it have to do with different browsers? Mozilla, Chrome, IE, Opera, etc have different companies running them or are open source.
It could be that each browser has a different default color so initial takes the color back to the browser default which may not necessarily be black in color.
Steven Parker221,293 Points
The choice should be based on intention.
If you want the color to be black, you should set it to black explicitly.
You would use "initial" if you wanted to set it to the color it would have if no value were set for any ancestor it might inherit from. Generally, this happens to be black but that's really up to the browser.