Skip to content

[css-values] Range restrictions with units are unclear #7584

@Loirooriol

Description

@Loirooriol

https://andreubotella.com/csswg-auto-build/css-values-4/#numeric-ranges

<length [0,100px]> indicates a length between 0px and 100px (expressed in any unit).

The problem is that, while all lengths have compatible units that can be converted into the canonical px, this may not be possible at parse time. For example,

Name: foo
Value: <length [0,100px]>
Initial: ''0px''
div {
  foo: 1em;
  font-size: 50px;
}

Then foo: 1em becomes 50px which is within the range. But

div {
  foo: 1em;
  font-size: 200px;
}

then foo: 1em becomes 200px, outside the range.

So how is foo: 1em validated? Is it always allowed and then clamped at computed-value time?

It may just be simpler to say that range restrictions with dimensions require one side to be 0 (optionally with a unit) and the other side to be or -∞.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions