[csswg-drafts] [selectors] Modifier for attribute selectors to split values into words (#14371)

SebastianZ has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors] Modifier for attribute selectors to split values into words ==
In https://github.com/w3c/csswg-drafts/issues/10001#issuecomment-5374412577 @paceaux suggested to introduce a new modifier `w` that changes the value matching to take word boundaries into account.

Taking the example from that comment, the selector

```css
[class^="foo" w]
```

allows to match all of

```html
<div class="foo-bar">
<div class="foo bar">
<div class="bar foo">
<div class="bar foo--baz">
```

Though it is not restricted to word prefixes. It could be used in any attribute selector.

So here are some more examples:

Matching suffixes is done via

```css
[data-values$="bar" w]
```

matches

´´´html
<div data-values="foo-bar">
<div data-values="foo-bar baz">
<div data-values="foo bar baz">
<div data-values="foobar baz">
```

Exact word matching (equivalent to `[attr~=value]`):

```css
[data-values="foo" w]
```

matches

```html
<div data-values="foo">
<div data-values="bar foo">
<div data-values="foo bar">
<div data-values="bar foo baz">
```

but not

```html
<div data-values="foobar">
<div data-values="foo-bar">
<div data-values="barfoo">
<div data-values="bar-foo">
```

Applied to `|=`:

```css
[data-values|="foo" w]

matches

```html
<div data-values="foo">
<div data-values="foo-bar">
<div data-values="baz foo">
<div data-values="baz foo-bar">
<div data-values="bar foo baz">
<div data-values="bar foo-baz biz">
```

but not

```html
<div data-values="foobar">
<div data-values="barfoo">
```

This can be seen as a counter-proposal to #14289 and covers more use cases than the ones outlined there.

Sebastian

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/14371 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 21 August 2026 21:25:16 UTC