Skip to content

[selectors-4] Exact attribute-substring matching #8124

@jakob-e

Description

@jakob-e

The current attribute substring allows matching start and end of value

[attr^="value"]

// Will match 
1 <div attr="value">
2 <div attr="value list">
3 <div attr="values">
4 <div attr="value-list">

To add precision the substring start/end (^$) could be combined with the whitespace-separated flag (~) to ensure an exact match of the substring - simplifying the current :is([attr="value"],[attr^="value "]) solution

[attr^~="value"]

// Would only match
1 <div attr="value">
2 <div attr="value list">

Syntax suggestion

[attr^~="value"] { ... }
[attr$~="value"] { ... }

Spec:
https://www.w3.org/TR/selectors-4/#attribute-representation
https://www.w3.org/TR/selectors-4/#attribute-substrings

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions