Open cdoublev opened 2 years ago
The mathematical definition of percentage (just another way of writing a number) and the CSS definition (a distinct unit separate from a number) are already different; we can't and don't want to unify them.
The <dimension-unit>
production appears to be correct and unambiguous. I suppose technically the definition in the next section is slightly incorrect:
If the result is a
<number-token>
, the substitution value is a dimension with the result’s value, and the given unit.
...and could have an "(or a percentage with the result's value)" appended to the end.
That said, I'd rather just clarify in Values that a percentage can also be considered to have a "unit" of %
; that would also fix the calculation tree reference. For all intents and purposes it does; the separation of dimensions and percentages is pretty much a legacy thing that I carried from CSS2's organization. For example, there is no meaningful difference between 1%
and 1vw
; both are numeric values with a unit indicating that it's 1/100th of some reference value.
I'd rather just clarify in Values that a percentage can also be considered to have a "unit" of
%
Alright, thanks.
CSS Values 5 defines
<dimension-unit>
as a literal "%" character (that is, a<delim-token>
with a value of "%") or an ident whose value is any of the CSS units for<length>
,<angle>
,<time>
,<frequency>
, or<flex>
values (such as px or ms).According to Wikipedia (sorry for not providing a more "academic" reference): A percentage is a dimensionless number (pure number); it has no unit of measurement.
According to Syntax,
<percentage-token>
has nounit
.I would like to suggest separating
%
from<dimension-unit>
and define<attr-type>
asstring | url | ident | color | number | percentage | length | angle | time | frequency | flex | '%' | <dimension-unit>
.The same confusion also exists in step 8.2 of simplify a calculation tree:
Imho, this can be reworded to For each set of root’s children that are
<number>
,<percentage>
,<dimension>
with an identicalunit
, [...].