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 trialShung Chen
6,526 Pointswhy is targeting .main-nav does not change the display of .main-nav li (its child element)
my question is why targeting .main-nav with display: inline; does not have any effect on its child element .main-nav li
in the video the code is shown as below
.name,
.main-nav,
.main-nav li{
display: inline;
}
If someone tries to omit the .main-nav li, the list elements will show as block element
1 Answer
Steven Parker
231,248 PointsCSS selectors are always specific and never include child elements of the one(s) selected.
You might be thinking of inheritance. Some properties of a parent element are inherited by their child elements, but whether a property is inherited or not depends on the particular property. A reference like MDN can be consulted to check if a specific property is inherited.
The display property being set in this particular rule is not inherited.