Selecting Descendants
Do you remember the family words from the HTML course? An element directly inside another element is its child. Its children, their children and so on are its descendants, and the element is their ancestor.
When you write two selectors separated by a space, you select the elements that match the second selector and are descendants of an element that matches the first one:
#breeds li {
color: purple;
}This rule selects the li elements inside the element with the id breeds. They aren’t its children, but its grandchildren: they are inside the ul, which is inside #breeds. That doesn’t matter, because the space selects descendants at any depth. A list in another part of the page wouldn’t be affected.
Don’t mix this up with chaining: div.group is a div with the class group, while div .group is an element with the class group inside a div.
Instructions
- 1
Text in a footer is usually less prominent than the rest of the page. Create a rule for
footer pthat sets a gray color:color: gray. Only the paragraphs in the footer will be gray, not those in the groups.