`<dashed-ident>` CSS type

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

The **<dashed-ident>** CSS data type is a case-sensitive {{cssxref("custom-ident")}} starting with two dashes that denotes an arbitrary string used as an {{glossary("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 {{cssxref("custom-ident")}}s, <dashed-ident>s are defined by the user. However, some <custom-ident>s are defined by the CSS language itself; <dashed-ident>s will always be defined by the user.

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](/en-US/docs/Web/CSS/Reference/Values/var).

css
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 {{cssxref("@color-profile")}} at-rule, the at-rule is declared first, and then the <dashed-ident> is used within a [CSS color() function](/en-US/docs/Web/CSS/Reference/Values/color_value/color).

css
@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 {{cssxref("@font-palette-values")}} at-rule, the at-rule is declared first, and then the <dashed-ident> is used as the value for the {{cssxref("font-palette")}} property.

css
@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 {{cssxref("env")}} CSS function, it can be updated using the {{cssxref("param")}} CSS function.

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

Specifications

{{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

  • {{cssxref("ident")}}
  • {{cssxref("custom-ident")}}