Given the following snippet, how can I use the parent class for styling the grandchild element?
<body>
<div class='parent'>
<ul>
<li>grandchild</li>
</ul>
</div>
</body>
Given the following snippet, how can I use the parent class for styling the grandchild element?
<body>
<div class='parent'>
<ul>
<li>grandchild</li>
</ul>
</div>
</body>
.wrapper * {
display: inline;
}
So what .wrapper * is telling is us to select any selector (* being the wildcard) that's nested in the .wrapper class.
If you want to recursively select ul elements inside of the .wrapper, you can just use what you already have. However, if you want only ul elements that are direct children of the div, you can use the .wrapper > ul selector.
You can also use .wrapper *:first-child to get the first element nestled inside the parent element.