[csswg-drafts] [css-content] Clarify valid and default values of `string-set` (#13244)

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

== [css-content] Clarify valid and default values of `string-set` ==
In the [2003 WD of CSS Content](https://www.w3.org/TR/2003/WD-css3-content-20030514/#strings), it was anticipated that the `string-set` property would take as its value a list of pairs of custom ident and _source_:

>  The 'string-set' property accepts values similar to the 'content' property, including the extraction of the current value of counters. 

> ~~~~ css
> META[author] { string-set: author attr(author); }
> HEAD > TITLE { string-set: title contents; }
> ~~~~

All subsequently released drafts of that module, including the [current ED](https://drafts.csswg.org/css-content-3/#string-set), limited the capability of this property *in prose*. It is supposed to effectively *always* store the equivalent of `content()` or `content(text)`:

> The `string-set` property copies the <mark>text content of an element</mark> into a named string, …

However, its syntax *requires* at least one [`<string>`](https://drafts.csswg.org/css-values-4/#string-value) after the initial custom identifier in order to select what should be stored in the named string:

> Value:  `none | [ <custom-ident> <string>+ ]#`

Accordingly, some of the following examples contain functions that return a `<string>`:

> ~~~~ css
> h2 { string-set: heading content() }
> ~~~~

> ~~~~ css
> h1 { string-set: header content(before) ':' content(text); }
> ~~~~

> ~~~~ css
> section { string-set: header attr(title) }
> ~~~~

However, the very first example contains the [keyword `contents`](https://drafts.csswg.org/css-content-3/#element-content) in place of a `<string>`:

> ~~~~ css
> H1 { string-set: chapter contents; }
> ~~~~

This keyword is specified in section 2.3 of the same module as part of the [`<content-list>` type](https://drafts.csswg.org/css-content-3/#content-values), which is strongly tailored to the `content` property.

> ~~~~ ebnf
> <content-list> = [ <string> | <image> | <attr()> | contents | <quote> | <leader()> | <target> | <string()> | <content()> | <counter> ]+
> ~~~~

In conclusion, please clarify the default and valid values of the `string-set` property, which might look like one of these:

1. `none | <custom-ident>` – suggested by current prose
2. `none | <custom-ident>#` – also consistent with current prose
3. `none | [ <custom-ident> <string>* ]#` – compromise between current syntax and prose
4. `none | [ <custom-ident> <string>+ ]#` – current syntax
5. `none | [ <custom-ident> <content-list>+ ]#` – suggested by examples
6. `none | [ <custom-ident> [ <string> | <counter> | <attr()>  | <content()>]* ]#` – covers all examples except the first which would be changed to use `content()` instead, also includes all types available in the fallback "/ alt" value of the `content` property

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


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

Received on Thursday, 18 December 2025 18:37:31 UTC