[csswg-drafts] [css-values] calc(): divide length by length to equal number? (#7448)

Myndex has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values] calc(): divide length by length to equal number? ==
The https://drafts.csswg.org/css-values/#calc-func does not indicate this implicitly (though it is tangentially implied in an example), though other docs do indicate that using calc() with a divide, requires the divisor to be a number, and not any form of unit. i.e.` calc(1ex / 1em) ` is illegal, and so is ` calc(1ex / 6px) ` only allowed is something like ` calc(1ex / 4) `.

Is there a specific reason that the right side *must* be a number, and can't be a value of the same type/subtype of unit?

I.e. I can see that 10px / 3deg makes no sense, but 10px / 3pt or 10px / 3em seem completely reasonable, but nevertheless will not evaluate.

An example application might be:

```css
span.helv { font-family: Helvetica; }
span.times { font-family: Times; }
span p { font-size: calc(10px / (1ex/1em)); }
```
So that
```html
<span class="helv"><p>This text is set to an x-height of 10px</p></span>
<span class="times"><p>This text is also set to an x-height of 10px</p></span>
```
Both lines here have the same x-height, as the font size is calculated as 10px divided by the x-height ratio, determined from 1ex/1em of the font family (inherited from the parent span). So for Helvetica, the font would be 19.3px, and for times it would be 22.2px.

It seems on the surface at least that dividing a length by a length is reasonable, and would be reasonable that the result was a unit-less number that could be used for further calculations. 


**Related**, the requirement that in a calc() where a multiplication is involved, at least one of the values must be a number, and again, it would seem that 6px * 3px should reasonably equal 12px.

**Related documentation issue:** the docs at Mozilla describe the current limitation more clearly than the CSS spec:  https://developer.mozilla.org/en-US/docs/Web/CSS/calc


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7448 using your GitHub account


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

Received on Friday, 1 July 2022 19:47:46 UTC