Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. CSS
  3. Reference
  4. At-rules
  5. @property
  6. initial-value

initial-value

Baseline 2024
Newly available

Since July 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Theinitial-value descriptor of the@propertyat-rule specifies the initial value for the registeredCSS custom property.It is a required descriptor unless thesyntax descriptor value is the universal syntax (*).If required but missing or invalid, the entire@property rule is invalid and ignored.

Syntax

css
/* Set initial color value */initial-value: rebeccapurple;/* Set initial length value */initial-value: 16px;

Values

A value that matches the type specified in thesyntax descriptor.For example, ifsyntax is<color>, then theinitial-value must be a validcolor value.

If the value of thesyntax descriptor is not the universal syntax definition, theinitial-value descriptor has to be acomputationally independent value. This means the value can be converted into a computed value without depending on other values, except for "global" definitions independent of CSS. For example,10px is computationally independent—it doesn't change when converted to a computed value.2in is also valid, because1in is always equivalent to96px. However,3em is not valid, because the value of anem is dependent on the parent'sfont-size.

Formal definition

Relatedat-rule@property
Initial valuen/a (required)
Computed valueas specified

Formal syntax

initial-value =
<declaration-value>?

Examples

Setting an initial value for a custom property

This example shows how to define a custom property--my-color with an initial color value of#c0ffee. This initial value will be used when the property is not inherited (inherits: false) and no other value is set on the element.

css
@property --my-color {  syntax: "<color>";  inherits: false;  initial-value: #c0ffee;}

UsingJavaScriptCSS.registerProperty():

js
window.CSS.registerProperty({  name: "--my-color",  syntax: "<color>",  inherits: false,  initialValue: "#c0ffee",});

Specifications

Specification
CSS Properties and Values API Level 1
# initial-value-descriptor

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp