Q. Which of the following CSS selectors selects an element if it is the only child of its parent?

  • (A) :nth-oftype(n)
  • (B) :only-child
  • (C) :root
  • (D) None of the above
πŸ’¬ Discuss
βœ… 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;
}
Explanation by: Tina Singh
Example: specify a background color for each element that is the only child of its parent:
p:only-child {
background: #ff0000;
}

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
228
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Tina Singh
Publisher
πŸ“ˆ
85%
Success Rate