CSSPropertyRule.initialValue

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.

Thuộc tính chỉ đọc initialValue của giao diện CSSPropertyRule trả về giá trị ban đầu của quy tắc thuộc tính CSS tùy chỉnh được đại diện bởi đối tượng @property.

Giá trị

Chuỗi trả về giá trị ban đầu của thuộc tính. Có thể là null nếu initial-value không được khai báo. Theo spec, đây là null chỉ khi cú pháp là "*".

Ví dụ

Stylesheet này chứa một đơn @property. CSSPropertyRule đầu tiên được trả về sẽ đại diện cho thuộc tính này.

css
@property --property-name {
  syntax: "<color>";
  inherits: false;
  initial-value: #c0ffee;
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].initialValue); // "#c0ffee"

Thông số kỹ thuật

Specification
CSS Properties and Values API Level 1
# dom-csspropertyrule-initialvalue

Tương thích trình duyệt