Learn
Selectors
Descendant Combinator
In CSS, the descendant combinator is used to target elements that are descendants of another element. It is represented by a space between two selectors.
For example, if you want to target all <p>
elements that are inside a <div>
element, you can use the following selector:
This selector will target all <p>
elements that are descendants of a <div>
element, no matter how deep they are nested.
You can also use the descendant combinator to target specific descendants of an element, like this:
This selector will only target <li>
elements that are descendants of a <ul>
element, which is a descendant of a div
element.
Instructions
Select the li
elements under the ul
element and add a margin-left
of 30px
.
Select the p
element inside the li
element with an id
of greece
and add a color
of blue
.
Select the img
elements inside the li
element with an id
of italy
and add a border
of 1px solid black
.
Sign up to start coding
Already have an account?
Sign In