Spec-Zone.ru › CSS

`inherits` CSS at-rule descriptor

Baseline Newly available

This feature works across the latest devices and browser versions. This feature might not work in older devices or browser versions. It's been available across browsers since July 2024.

The inherits CSS descriptor of the @property at-rule controls whether or not the registered CSS custom property inherits by default. It is a required descriptor; if missing or invalid, the entire @property rule is invalid and ignored.

Syntax

/* Custom property does not inherit values */
inherits: false;

/* Custom property inherits values */
inherits: true;

Values

true
The property inherits by default.
false
The property does not inherit by default.

Formal definition

Formal syntax

Examples

Setting inheritance behavior of a custom property

This example shows how to define a custom property --my-color that does not inherit its value from its parent elements:

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

Using JavaScript CSS.registerProperty():

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

Specifications

Specification
CSS Properties and Values API Level 1
# inherits-descriptor

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on iOS Samsung Internet WebView Android WebView on iOS
inherits
85
85
128
71
16.4
85
128
60
16.4
14.0
85
16.4

See also

  • Other @property descriptors: initial-value and syntax
  • Registering CSS custom properties
  • CSS Properties and Values API
  • CSS Painting API
  • CSS Typed Object Model
  • Houdini APIs

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@property/inherits

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API