Closed chrislachance closed 2 years ago
I think rch
and ric
seem pretty reasonable to add. I'm a little skeptical about rex
though. When setting line-height on the root you can just use ex
. Beyond that you probably want to match the root's line rhythm, whatever it is.
What's an example of a page in which rch
is necessary and ch
itself is insufficent?
Sure, I put together an example of what this might look like.
I'm also going to update the proposal, looks like the only way to do the workaround is using JS that creates custom properties, which unfortunately creates layout instability if not properly handled.
Demo https://codepen.io/chrislachance/pen/zYoJPvP?editors=1100
PS: How would you use the root's line-height however for setting padding, etc? As aside, seems strange to me that line-height uses EM instead of EX as well. Various fonts sit very differently within the space allotted for them, and EX targets the actual size of the font's x (hopefully), not the generic pixel bounding box set by font-size. (Think I've understood that logic properly.)
One more example of how REM fails to cap character count accurately when a font that is miniature is saying its 16px. https://codepen.io/chrislachance/pen/QWGVQme?editors=1100
Agenda+ to discuss whether to add rch
and ric
.
@chrislachance Wrt the relationship of glyph size and line height, you might want to see the latest proposals in css-inline-3. https://www.w3.org/TR/css-inline-3/#line-height particularly text-edge and leading-trim.
Text-edge stuff & leading-trim look awesome. Very exciting.
As for RIC, don't think I'm familiar with that measurement, didn't see it in issue tracker. I assume you mean REX as proposed above?
Finally, thanks for the heads-up & for considering for review.
If we're going to do this addition (I don't personally have a clear idea of how useful it'll be, but also don't see any reason to oppose it), then I think we should consider simply having r
versions of all the font-relative units in https://drafts.csswg.org/css-values-4/#font-relative-lengths. So that would mean adding rcap
as well as rex
, rch
, and ric
.
(No, I don't have a concrete use case for it. But it seems logical to do the full set, so that authors know that for any font-relative unit, they have both the "local" value and the root-element value available, rather than trying to pick and choose which of the units get a root-element version and which don't.)
This seems reasonable. Low implementation cost.
The CSS Working Group just discussed rch and rex
, and agreed to the following:
RESOLVED: Add root-relative variants of *all* the font-relative units, named r*
Edits checked in and republished on /TR.
Background
Currently today, there is support for relative root level 'em' width, aka. 'rem' (https://www.w3.org/TR/css3-values/#rem), but not root 'ch' nor root 'ex' (https://www.w3.org/TR/css3-values/#font-relative-lengths). I'd like to see that change.
Proposal
When considering WCAG 2.1 1.4.8 (https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-visual-presentation.html), its pretty clear that a value like 80rem won't guarantee a layout will meet this requirement. I believe that something like 80rch would be far more effective (or at least a lot closer to achieving this without JS).
As for 'rex' (which honestly would be really fun to use), some typography and visual designers suggest that vertical rhythm in a design should be driven by x-height (or 'ex'). (#22 - https://uxdesign.cc/the-ui-ux-tips-collection-volume-one-f69f0969ed17#ebf5). Using the baseline font (user preference or design choice), the design should vertically scale accordingly.
Using 'rem' / 'rch' for horizontal spacing & 'rex' for vertical seems to be more inline with the intent of spacing metrics, that are fluid based on the user's preference or style-set font family.
Advantages and Drawbacks
Current Workarounds
P.S. This is my first time proposing. Thanks to Adam Argyle for pointing me in the right direction (especially to proposal with a nice template to follow!)