Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

ident() — identifier from computed pieces

`ident()` is a CSS Values 5 arbitrary-substitution function intended to build an identifier from strings, integers, and identifiers.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

ident( <ident-arg>+ )

ident() is a CSS Values 5 arbitrary-substitution function intended to build an identifier from strings, integers, and identifiers.

Normatively ident("card-" 7) should build card-7, but this Chromium returns false. The control keeps cktis-baseline, while the declaration containing the function computes to none; ident("") also reports support false.

Grammar: ident( <ident-arg>+ ).

The function has one free-form argument containing one or more pieces; after substitution it serializes and concatenates them without separators. ident(-- attr(id)) can construct a dashed identifier. An empty result, a piece other than a string, integer, or identifier, or a result that cannot be represented as an identifier becomes the guaranteed-invalid value. CSS Values 5 remains in early exploration, so use requires a support test and a safe alternative.

Examples

const control=document.createElement('div');control.id='ident-control';const probe=document.createElement('div');probe.id='ident-probe';probe.dataset.id='7';document.body.append(control,probe);
const style=document.createElement('style');style.textContent='#ident-control,#ident-probe{animation-name:cktis-baseline}#ident-probe{animation-name:ident("card-" attr(data-id))}';document.head.append(style);
const supported=CSS.supports('view-transition-name','ident("card-" 7)');
const emptySupported=CSS.supports('view-transition-name','ident("")');
console.log('supported='+supported+'; control='+getComputedStyle(control).animationName+'; ident-result='+getComputedStyle(probe).animationName+'; empty-result-supported='+emptySupported);

Result

supported=false; control=cktis-baseline; ident-result=none; empty-result-supported=false

`ident()` is a CSS Values 5 arbitrary-substitution function intended to build an identifier from strings, integers, and identifiers.

Sources