Q. Which of the following CSS selectors selects an element if it is the only child of its parent?
β
Correct Answer: (B)
:only-child
Explanation: Example: specify a background color for each element that is the only child of its parent:
p:only-child {
background: #ff0000;
}
p:only-child {
background: #ff0000;
}