Skip to content

Commit 95f91ae

Browse files
committed
Better clarify how rem/rlh fall back.
1 parent 09f68b4 commit 95f91ae

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

css-values-3/Overview.bs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -915,12 +915,8 @@ Relative lengths</h3>
915915
<h4 id="font-relative-lengths">
916916
Font-relative lengths: the ''em'', ''ex'', ''ch'', ''rem'' units</h4>
917917

918-
Aside from ''rem'' (which refers to the font-size of the root element),
919-
the <dfn export id="font-relative-length">font-relative lengths</dfn> refer to the font metrics of the element on which they are used.
920-
The exception is when they occur in the value of the 'font-size' property itself,
921-
in which case they refer to the computed font metrics of the parent element
922-
(or the computed font metrics corresponding to the initial values of the 'font' property,
923-
if the element has no parent).
918+
The <dfn export id="font-relative-length">font-relative lengths</dfn> refer to the font metrics of the element on which they are used,
919+
or, in the case of ''rem'', the metrics of the root element).
924920

925921
<dl export dfn-type=value dfn-for="<length>">
926922
<dt><dfn id="em" lt="em">em unit</dfn>
@@ -976,10 +972,20 @@ Font-relative lengths: the ''em'', ''ex'', ''ch'', ''rem'' units</h4>
976972
<dt><dfn id="rem" lt="rem">rem unit</dfn>
977973
<dd>
978974
Equal to the computed value of 'font-size' on the root element.
979-
When specified on the 'font-size' property of the root element,
980-
the ''rem'' units refer to the property's <em>initial value</em>.
975+
976+
If used in the 'font-size' property of the root element,
977+
or in a document with no root element,
978+
''1rem'' is equal to the initial value of the 'font-size' property.
981979
</dl>
982980

981+
When used in the value of the 'font-size' property on the element they refer to,
982+
these units refer to the computed font metrics of the parent element
983+
(or the computed font metrics corresponding to the initial values of the 'font' property,
984+
if the element has no parent).
985+
When used outside the context of an element
986+
(such as in <a>media queries</a>),
987+
these units refer to the computed font metrics corresponding to the initial values of the 'font' property.
988+
983989
<!--
984990
██ ██ ██ ██ ██ ████████ ████████ ██████
985991
██ ██ ██ ██ ██ ██ ██ ██ ██ ██

css-values/Overview.bs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -921,17 +921,8 @@ Relative lengths</h3>
921921
<h4 id="font-relative-lengths">
922922
Font-relative lengths: the ''em'', ''ex'', ''ch'', ''ic'', ''rem'', ''lh'', ''rlh'' units</h4>
923923

924-
Aside from ''rem'' (which refers to the font-size of the root element)
925-
and ''rlh'' (which refers to the line-height of the root element),
926-
the <dfn export id="font-relative-length">font-relative lengths</dfn> refer to the font metrics of the element on which they are used.
927-
The exception is when they occur in the value of the 'font-size' property itself,
928-
in which case they refer to the computed font metrics of the parent element
929-
(or the computed font metrics corresponding to the initial values of the 'font' property,
930-
if the element has no parent).
931-
In addition, if the ''lh'' unit is used in the value of the 'line-height' property,
932-
it also refer to the computed metrics on the parent element
933-
(or the computed metrics corresponding to the initial values of the 'font' and 'line-height' properties,
934-
if the element has no parent).
924+
The <dfn export id="font-relative-length">font-relative lengths</dfn> refer to the font metrics of the element on which they are used,
925+
or, in the case of ''rem'' and ''rlh'', the metrics of the root element).
935926

936927
<figure>
937928
<img src="images/Typography_Line_Terms.svg" 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.">
@@ -1050,6 +1041,16 @@ Font-relative lengths: the ''em'', ''ex'', ''ch'', ''ic'', ''rem'', ''lh'', ''rl
10501041
the 'max-lines' property shall be used instead.
10511042
</dl>
10521043

1044+
When used in the value of the 'font-size' property
1045+
(or the 'line-height' property, for the ''lh'' and ''rlh'' units)
1046+
on the element they refer to,
1047+
these units refer to the computed font metrics of the parent element
1048+
(or the computed font metrics corresponding to the initial values of the 'font' property,
1049+
if the element has no parent).
1050+
When used outside the context of an element
1051+
(such as in <a>media queries</a>),
1052+
these units refer to the computed font metrics corresponding to the initial values of the 'font' and/or 'line-height' properties.
1053+
10531054
<!--
10541055
██ ██ ██ ██ ██ ████████ ████████ ██████
10551056
██ ██ ██ ██ ██ ██ ██ ██ ██ ██

0 commit comments

Comments
 (0)