1

I'm trying to define a CSS @property rule for a font-size with a rem-based initial value.

https://developer.mozilla.org/en-US/docs/Web/CSS/@property

It works as long as no syntax is defined:

@property --font-size {
  syntax: '*';
  initial-value: 2rem;
}

But when setting the length syntax, which includes rem units based on the docs, it's ignored by browser:

@property --font-size {
  syntax: '<length>';
  initial-value: 2rem;
}

Example: https://stackblitz.com/edit/stackblitz-starters-axmosbgb?file=styles.css

1 Answer 1

2

The initial value must be "computationally independent" so you cannot rely on units such as rem or em

Otherwise, if the value of the syntax descriptor is not the universal syntax definition, the following conditions must be met for the @property rule to be valid:

  • The initial-value descriptor must be present.

  • The initial-value descriptor’s value must parse successfully according to the grammar specified by the syntax definition.

  • The initial-value must be computationally independent.

https://www.w3.org/TR/css-properties-values-api-1/#initial-value-descriptor

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.