Skip to content

[css-selectors] has-child selector #4903

Description

@chrishtr

Proposal: add a selector that matches an element if a direct child matches the selector in the function.

"all a elements that contain an img" -> a:has-child(img)

Motivation: #2 missing-features request in the state-of-CSS 2019 survey.

Since it only matches direct children, it may be no more expensive than sibling selectors.

A related selector that was considered and removed as too expensive and slow (AIUI) is :has. See also resolution regarding it here.

@tabatkins @lilles

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions