How can you target an element that is the only child of its parent using a pseudo-class?
- :first-child
- :last-child
- :nth-child(1)
- :only-child
To target an element that is the only child of its parent, you can use the :only-child pseudo-class. This selector is used when you want to apply styles or behavior to an element that is the only child within its parent container. For instance, you might want to style a single button in a list of buttons.
Loading...
Related Quiz
- Which CSS pseudo-class would allow you to target only the last list item in an unordered list?
- Which CSS property is used to specify the number of times an animation should run?
- How can you set a fallback font in case the primary font fails to load?
- When an animation is paused using the animation-play-state property, its current state is determined by the ________ property.
- What is the purpose of the @keyframes rule in CSS?