大网数据广告活动
Web 标准与前端开发

`<dashed-ident>` CSS type

· 52CE 我爱测

The **`<dashed-ident>`** CSS data type is a case-sensitive custom-ident starting with two dashes that denotes an arbitrary string used as an identifier.

The <dashed-ident> CSS data type is a case-sensitive custom-ident starting with two dashes that denotes an arbitrary string used as an identifier.

Syntax

The syntax of <dashed-ident> is similar to CSS identifiers (such as property names), except that it is case-sensitive. It is a user-defined identifier preceded by two dashes (--).

The double dash at the beginning makes them easily identifiable when reading through a CSS code block, and helps to avoid name clashes with standard CSS keywords.

Just like custom-idents, <dashed-ident>s are defined by the user. However, some <custom-ident>s are defined by the CSS language itself; <dashed-ident>s will never be defined in CSS.

Examples

Using with CSS custom properties

When a <dashed-ident> is used as a CSS custom property, the property is declared first, and then the <dashed-ident> is used within a CSS var() function.

html {
  --primary-color: red;
  --secondary-color: blue;
  --tertiary-color: green;
}

h1,
h4 {
  color: var(--primary-color);
}

h2,
h5 {
  color: var(--secondary-color);
}

h3,
h6 {
  color: var(--tertiary-color);
}

Using with @color-profile

When a <dashed-ident> is used with the @color-profile at-rule, the at-rule is declared first, and then the <dashed-ident> is used within a CSS color() function.

@color-profile --my-color-profile {
  src: url("https://example.org/SWOP2006_Coated5v2.icc");
}

.header {
  background-color: color(--my-color-profile 0% 70% 20% 0%);
}

Using with @font-palette-values

When a <dashed-ident> is used with the @font-palette-values at-rule, the at-rule is declared first, and then the <dashed-ident> is used as the value for the font-palette property.

@font-palette-values --my-palette {
  font-family: "Bixa";
  base-palette: 1;
  override-colors: 0 red;
}

h1,
h2,
h3,
h4 {
  font-palette: --my-palette;
}

Using with env() and param()

When a <dashed-dent> is used in an external resource in an env CSS function, it can be updated using the param CSS function.

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <path fill="env(--color, black)" d="..." />
</svg>
path:hover {
  link-parameters: param(--color, tomato);
}

Specifications

Browser compatibility

As this type is not a real type but a convenience type used to simplify the definition of other CSS syntax, there is no browser compatibility information as such.

See also

  • ident
  • custom-ident

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。