Skip to content

Commit 5d284d0

Browse files
committed
[css-values-4] Define root-relative variants of all font-relative units. w3c#6034
1 parent d27d020 commit 5d284d0

1 file changed

Lines changed: 57 additions & 40 deletions

File tree

css-values-4/Overview.bs

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,11 +1591,14 @@ Relative Lengths</h3>
15911591
-->
15921592

15931593
<h4 id="font-relative-lengths">
1594-
Font-relative Lengths: the ''em'', ''ex'', ''cap'', ''ch'', ''ic'', ''rem'', ''lh'', ''rlh'' units</h4>
1594+
Font-relative Lengths: the ''em'', ''rem'', ''ex'', ''rex'', ''cap'', ''rcap'', ''ch'', ''rch'', ''ic'', ''ric'', ''lh'', ''rlh'' units</h4>
15951595

15961596
The <dfn export id="font-relative-length">font-relative lengths</dfn>
1597-
refer to the font metrics of the element on which they are used--
1598-
or, in the case of ''rem'' and ''rlh'', the metrics of the root element.
1597+
refer to the font metrics
1598+
either of the element on which they are used
1599+
(for the <dfn>local font-relative lengths</dfn>)
1600+
or of the root element
1601+
(for the <dfn>root font-relative lengths</dfn>).
15991602

16001603
<figure>
16011604
<img src="images/Typography_Line_Terms.svg" width=361 height=97 alt="The word 'Sphinx' annotated with various font metrics: ascender height, to the top of the h's serif; cap height, to the visually approximate top of the S; the x height, to the visually approximate top of the x; the baseline, along the bottom of S, h, i, n, and x; and the descender height, to the bottom fo the p.">
@@ -1624,6 +1627,14 @@ Font-relative Lengths: the ''em'', ''ex'', ''cap'', ''ch'', ''ic'', ''rem'', ''l
16241627
will be 20% greater than the computed font size inherited by <code>h1</code> elements.
16251628
</div>
16261629

1630+
<dt><dfn id="rem" lt="rem">rem unit</dfn>
1631+
<dd>
1632+
Equal to the computed value of the ''em'' unit on the root element.
1633+
1634+
<wpt>
1635+
css/css-values/calc-rem-lang.html
1636+
</wpt>
1637+
16271638
<dt><dfn id="ex" lt="ex">ex unit</dfn>
16281639
<dd>
16291640
Equal to the used x-height of the <a href="https://www.w3.org/TR/css3-fonts/#first-available-font">first available font</a> [[!CSS3-FONTS]].
@@ -1659,6 +1670,10 @@ Font-relative Lengths: the ''em'', ''ex'', ''cap'', ''ch'', ''ic'', ''rem'', ''l
16591670
css/css-values/calc-ch-ex-lang.html
16601671
</wpt>
16611672

1673+
<dt><dfn id="rex" lt="rex">rex unit</dfn>
1674+
<dd>
1675+
Equal to the value of the ''rex'' unit on the root element.
1676+
16621677
<dt><dfn id="cap" lt="cap">cap unit</dfn>
16631678
<dd>
16641679
Equal to the used cap-height of the <a href="https://www.w3.org/TR/css3-fonts/#first-available-font">first available font</a> [[!CSS3-FONTS]].
@@ -1674,6 +1689,10 @@ Font-relative Lengths: the ''em'', ''ex'', ''cap'', ''ch'', ''ic'', ''rem'', ''l
16741689
In the cases where it is impossible or impractical to determine the cap-height,
16751690
the font's ascent must be used.
16761691

1692+
<dt><dfn id="rcap" lt="rcap">rcap unit</dfn>
1693+
<dd>
1694+
Equal to the value of the ''rcap'' unit on the root element.
1695+
16771696
<dt><dfn id="ch" lt="ch">ch unit</dfn>
16781697
<dd>
16791698
Equal to the used <a>advance measure</a> of the “0” (ZERO, U+0030) glyph
@@ -1712,6 +1731,10 @@ Font-relative Lengths: the ''em'', ''ex'', ''cap'', ''ch'', ''ic'', ''rem'', ''l
17121731
css/css-values/calc-ch-ex-lang.html
17131732
</wpt>
17141733

1734+
<dt><dfn id="rch" lt="rch">rch unit</dfn>
1735+
<dd>
1736+
Equal to the value of the ''rch'' unit on the root element.
1737+
17151738
<dt><dfn id="ic" lt="ic">ic unit</dfn>
17161739
<dd>
17171740
Equal to the used <a>advance measure</a> of the “水” (CJK water ideograph, U+6C34) glyph
@@ -1737,16 +1760,9 @@ Font-relative Lengths: the ''em'', ''ex'', ''cap'', ''ch'', ''ic'', ''rem'', ''l
17371760
css/css-values/ic-unit-012.html
17381761
</wpt>
17391762

1740-
<dt><dfn id="rem" lt="rem">rem unit</dfn>
1763+
<dt><dfn id="ric" lt="ric">ric unit</dfn>
17411764
<dd>
1742-
Equal to the computed value of 'font-size' on the root element.
1743-
When specified in the 'font-size' property of the root element,
1744-
or in a document with no root element,
1745-
''1rem'' is equal to the initial value of the 'font-size' property.
1746-
1747-
<wpt>
1748-
css/css-values/calc-rem-lang.html
1749-
</wpt>
1765+
Equal to the value of the ''ric'' unit on the root element.
17501766

17511767
<dt><dfn id="lh" lt="lh">lh unit</dfn>
17521768
<dd>
@@ -1762,8 +1778,7 @@ Font-relative Lengths: the ''em'', ''ex'', ''cap'', ''ch'', ''ic'', ''rem'', ''l
17621778

17631779
<dt><dfn id="rlh" lt="rlh">rlh unit</dfn>
17641780
<dd>
1765-
Equal to the computed value of 'line-height' property on the root element,
1766-
converting ''line-height/normal'' to an absolute length as above.
1781+
Equal to the value of the ''lh'' unit on the root element.
17671782

17681783
Note: Setting the 'height' of an element using either the ''lh'' or the ''rlh'' units
17691784
does not enable authors to control the actual number of lines in that element.
@@ -1778,44 +1793,46 @@ Font-relative Lengths: the ''em'', ''ex'', ''cap'', ''ch'', ''ic'', ''rem'', ''l
17781793

17791794
</dl>
17801795

1781-
Issue: We can potentially add more typographic units,
1782-
like cicero, didot, etc.
1783-
They're just absolute units,
1784-
and so can be done with the existing units,
1785-
but is there enough desire for them
1786-
(potentially for printing use-cases)
1787-
that it would be worth adding them?
1788-
Or should we just wait for Houdini Custom Units?
1789-
1790-
Some user-agents allow users to apply additional restrictions to font sizes in a document,
1791-
such as setting minimum font sizes to ensure readability.
1792-
When used in the context of an element,
1793-
these additional restrictions must be applied to the [=used value=] of these properties only;
1794-
they <em>must not</em> affect the resolution of relative units.
1795-
1796-
When used outside the context of an element
1797-
(such as in <a>media queries</a>),
1798-
these units refer to the metrics corresponding
1799-
to the initial values of the 'font' and 'line-height' properties.
1800-
In this context,
1801-
the units must apply any additional restrictions to the values,
1802-
contrary to the normal behavior mentioned above.
1803-
18041796
When used in the value of the 'font-size' property on the element they refer to,
1805-
they resolve against the computed metrics of the parent element--
1797+
the [=local font-relative lengths=] resolve against the computed metrics of the parent element--
18061798
or against the computed metrics corresponding to the initial values
18071799
of the 'font' and 'line-height' properties,
18081800
if the element has no parent.
1809-
Additionally,
1801+
Likewise,
18101802
when ''lh'' or ''rlh'' units are used
18111803
in the value of the 'line-height' property on the element they refer to,
18121804
they resolve against the computed 'line-height' and font metrics of the parent element--
18131805
or the computed metrics corresponding to the initial values
18141806
of the 'font' and 'line-height' properties,
18151807
if the element has no parent.
1816-
(The other font-relative units continue to resolve against
1808+
(The other font-relative lengths continue to resolve against
18171809
the element’s own metrics when used in 'line-height'.)
18181810

1811+
When used outside the context of an element
1812+
(such as in <a>media queries</a>),
1813+
the [=font-relative lengths=] units refer to the metrics corresponding
1814+
to the initial values of the 'font' and 'line-height' properties.
1815+
Similarly, when specified in a document with no root element,
1816+
the [=root font-relative lengths=] are resolved
1817+
assuming the initial values of the 'font' and 'line-height' properties..
1818+
1819+
Some user-agents allow users to apply additional restrictions to font sizes in a document,
1820+
such as setting minimum font sizes to ensure readability.
1821+
Such restrictions must be applied to the [=used value=] of the affected properties only;
1822+
they <em>must not</em> affect the resolution of [=font-relative lengths=] used in properties.
1823+
However, in other contexts
1824+
(such as in [=media queries=]),
1825+
to the extent that they would impact the used font metrics,
1826+
such restrictions <em>do</em> affect the resolution of [=font-relative lengths=].
1827+
1828+
Note: In general, respecting a user's preferences, like minimum font sizes,
1829+
is desirable;
1830+
it's useful for a media query like ''(min-width: 40em)''
1831+
to use the actual font size the document will be displayed in.
1832+
However, having these preferences affect font-relative lengths <em>in properties on an element</em>
1833+
was found to not be Web-compatible;
1834+
too many pages expect these units to be exact multiples of the specified 'font-size',
1835+
rather than the <em>actual</em> font-size after applying user preferences.
18191836

18201837
<!--
18211838
██ ██ ██ ██ ██ ████████ ████████ ██████

0 commit comments

Comments
 (0)