初始值
initial-value CSS描述符在使用@property at-rule的时候是必需的,除非 syntax 属性接受了任何有效的 token 流。它为属性设置初始值。
被选定为initial-value的参数,依照syntax描述符定义,必须可以正确地解析。因此,如果syntax描述符为<color>,那么初始值必须是一个有效的color值。
语法
css
@property --property-name {
  syntax: '<color>';
  inherits: false;
  initial-value: #c0ffee;
}
@property --property-name {
  syntax: '<color>';
  inherits: true;
  initial-value: #c0ffee;
}
取值
对于设定的syntax,具有正确值的字符串。
标准定义
标准语法
css
initial-value =   <declaration-value>  
实例
为 --my-color 自定义属性添加颜色值类型检测、设置默认值并且设置属性值不允许被继承。
css
@property --my-color {
  syntax: '<color>';
  inherits: false;
  initial-value: #c0ffee;
}
使用 JavaScript 中的 CSS.registerProperty (en-US)函数:
js
window.CSS.registerProperty({
  name: '--my-color',
  syntax: '<color>',
  inherits: false,
  initialValue: '#c0ffee',
});
标准语法
css
initial-value =   <declaration-value>  
规范
| Specification | 
|---|
| CSS Properties and Values API Level 1  # initial-value-descriptor  | 
浏览器兼容性
BCD tables only load in the browser