Re: [csswg-drafts] [css-values-4] What happens to sign(%) when % has no meaning? (#12204)

`1% - 1` fails due to a type mismatch (adding the types returns failure); it's an invalid calculation no matter what it's used in. (Percents never resolve against pure numbers in a calc sense, to avoid ambiguous types.)

Per spec, `z-index: sign(10%)` is invalid as well. Since the % doesn't resolve against anything, its type is `[percent=>1]` with a percent hint of "percent", per ["resolve a type"](https://drafts.csswg.org/css-values/#determine-the-type-of-a-calculation).  `sign()` then returns a number, [made consistent](https://drafts.csswg.org/css-values/#css-make-a-type-consistent) with its input; this gives it a type of `[]` with a percent hint of "percent". This then fails to match `<number>`, per the ["match" operation](https://drafts.css-houdini.org/css-typed-om-1/#cssnumericvalue-match), because %s aren't allowed in this context and so it only matches `<number>` if its percent hint is null.

So Chrome and Firefox are currently correct, Safari is wrong.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12204#issuecomment-2898786992 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 21 May 2025 17:56:45 UTC