[csswg-drafts] [css-values] New units for <percentage> based on existing usage (#5551)

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

== [css-values] New units for <percentage> based on existing usage ==
`<percentage>` can be used interchangeably in some places with other numeric notations. In other properties, unitless numeric notation is used exclusively although it looks and works a lot like percentages. I propose that this be generalized and harmonized.

- [`font-weight`](https://drafts.csswg.org/css-fonts/#font-weight-numeric-values) before Level 3 had "numeric keywords" `100`, `200` through `900` and now accepts an integer number with one to three digits, [1, 1000].
- some [`<color>`](https://drafts.csswg.org/css-color/#typedef-color) components, in particulkar inside [`color()`](https://drafts.csswg.org/css-color/#color-function), can be provided as floating point numbers in the range [0.0, 1.0], either specified as [`<number>`](https://drafts.csswg.org/css-color/#typedef-alpha-value) or as [`<number-percentage>`](https://drafts.csswg.org/css-values-3/#typedef-number-percentage)
- [sRGB `<color>`](https://drafts.csswg.org/css-color/#rgb-functions) components can be provided as integer numbers in the 8-bit (i.e. 1-byte) range [0, 255], optionally in hexadecimal notation [00h, FFh]
- sRGB `<color>` components can be provided as hexadecimal integer numbers in the 4-bit (i.e. 1-nibble) range [0, F], i.e. [0, 15], although this is only supported in [three- and four-char hexcodes](https://drafts.csswg.org/css-color/#hex-notation) and not in common functional notation
- `font-feature-settings`and similar oney kind of accept integers as boolean values in the range [0, 1], i.e. out of the set {0, 1}

In order to accommodate 10-bit and 12-bit color channels, the byte integers are to be relaxed to become floating point numbers. Alternatively, they would have needed some way to represent the ranges [0, 1023] and [0, 4095], respectively. #480

I propose that we treat all of the cases mentioned above as special cases where it is allowed to omit the unit, as it is for `deg` in `<hue>`s. They would thus become special cases of the `<percentage>` value type. Therefore, we would need units for them elsewhere. Here is a first suggestion:

- **`pm`**, _per mille_ (‰) for `<font-weight>`: [0, 1000]
- **`u`**, _unity_: [0.0, 1.0]
- **`b`** or `byte`, _byte_: [0, 255]
- **`h`**, `hex` _hexadecimal_ or **`n`** _nibble_: [0, 15]
- **`k`**, _kibibit_: [0, 1023]
- **`t`** _tribble_ or perhaps `w`, _word_:  [0, 4095]
- ~~`bool`, _boolean_: [0, 1] (`true` and `false` global keywords are a non-starter)~~

The following examples would become valid then:

- `color: rgba(50%, 0.5u, 127b, 7h);`
- `color: rgb(123b, 456k, 789t);`
- `font-weight: 50%;`

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


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

Received on Friday, 25 September 2020 11:36:54 UTC