Skip to content

CSS Selectors

Only Child

About

The :only-child pseudo-class matches an element if it's the only child of its parent. It's the short form of :first-child:last-child.

Only child

The selector matches the p element as it's the only child of its parent.

Multiple children

The selector doesn't match any element as there are multiple children.