w3c / w3c/csswg-drafts

[selectors-4] Exact attribute-substring matching

Open
#8,124 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

selectors-4
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the Selectors Level 4 sections on attribute representation and attribute substrings linked in the issue, then review the existing comment discussion. Determine whether combining substring and whitespace-separated matching is a specification-compatible proposal; done means reaching and documenting a Working Group decision in the relevant draft.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.