Odpowiedź :
Odpowiedź:
Stack Overflow
Sign upLog in
Questions
Jobs
Tags
Users
Badges
Ask
Up vote0Down vote
CSS Select Grandchild Element - Without adding new HTML/ID's/ or !important
html css css-selectors grandchild
I am learning about parent and child elements and I am trying to figure out how to select/style a grandchild element that is nested inside 3 div's without adding additional classes, ID's, or !important to resolve it. The parent div has a class of "grandchild" and there are two other div's that share the same class. I need to style only "Aaron" without selecting the other p tags associated with same class "grandchild".
<div class="parent"> <!-- red --> <p>Jane</p> <div class="child"> <!-- blue --> <p>Jim</p> <div class="grandchild"> <!-- green --> <p>Aaron</p> <!--------------------Style ONLY this one-----> <div class="greatgrandchild"> <!-- pink --> <p>Victoria</p> </div> <div class="greatgrandchild greatgrandchild2"> <!-- purple --> <p>Devin</p> </div> <!-- grandchild2 --> </div> <!-- grandchild --> </div> <!-- child --> <div class="child child2"> <!-- coral --> <p>Susan</p> <div class="grandchild"> <!-- aqua --> <p>George</p> <div class="greatgrandchild"> <!-- rosybrown --> <p>Julie</p> </div> </div> <div class="grandchild grandchild2"> <!-- sienna --> <p>Nancy</p> <div class="greatgrandchild"> <!-- tomato --> <p>Bob</p> </div> </div> <!-- grandchild --> </div> </div> <!-- parent -->
Wyjaśnienie:
powinno być dobrze ale nie jestem pewna