Skip to content

Commit b9e2fff

Browse files
committed
[css-fonts-4] Clean up font property section
1 parent d056e0d commit b9e2fff

1 file changed

Lines changed: 206 additions & 153 deletions

File tree

css-fonts-4/Overview.bs

Lines changed: 206 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,174 +1092,227 @@ Relative sizing: the 'font-size-adjust' property</h3>
10921092
<h3 id="font-prop">
10931093
Shorthand font property: the 'font' property</h3>
10941094

1095-
<pre class="propdef">
1096-
Name: font
1097-
Value: [ [ <<'font-style'>> || <<font-variant-css2>> || <<'font-weight'>> || <<font-stretch-css3>> ]? <<'font-size'>> [ / <<'line-height'>> ]? <<'font-family'>> ] | caption | icon | menu | message-box | small-caption | status-bar
1098-
Initial: see individual properties
1099-
Applies to: all elements
1100-
Inherited: yes
1101-
Percentages: see individual properties
1102-
Computed value: see individual properties
1103-
Media: visual
1104-
Animatable: see individual properties
1105-
</pre>
1106-
1107-
The 'font!!property' property is,
1108-
except as described below,
1109-
a shorthand property for setting
1110-
'font-style!!property', 'font-variant!!property', 'font-weight!!property', 'font-stretch!!property',
1111-
'font-size!!property', 'line-height', 'font-family!!property'
1112-
at the same place in the stylesheet.
1113-
Values for the 'font-variant!!property' property can also be included
1114-
but only those supported in CSS 2.1;
1115-
none of the 'font-variant!!property' values added in this specification can be used in the
1116-
'font!!property' shorthand:
1117-
1118-
<pre class="prod"><dfn id="font-variant-css21-values"><<font-variant-css2>></dfn> = [normal | small-caps]</pre>
1119-
1120-
Values for the 'font-stretch!!property' property can also be included but only those supported in
1121-
CSS Fonts level 3, none of the 'font-stretch!!property' values added in this specification can be used in the 'font' shorthand:
1122-
1123-
<pre class="prod"><dfn id="font-stretch-css3-values"><<font-stretch-css3>></dfn> = [normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded]</pre>
1124-
1125-
The syntax of this property is based on a traditional typographical
1126-
shorthand notation to set multiple properties related to fonts.
1127-
1128-
All subproperties of the 'font!!property' property are first reset to their initial values,
1129-
including those listed above plus 'font-size-adjust', 'font-kerning', all subproperties of 'font-variant!!property', 'font-feature-settings!!property',
1130-
'font-language-override!!property', 'font-min-size', 'font-max-size', 'font-optical-sizing', 'font-variation-settings!!property', and 'font-palette'.
1131-
Then, those properties that are given explicit values in the 'font!!property'
1132-
shorthand are set to those values. For a definition of allowed and
1133-
initial values, see the previously defined properties. For reasons of
1134-
backwards compatibility, it is not possible to set 'font-size-adjust'
1135-
to anything other than its initial value using the 'font'
1136-
shorthand property; instead, use the individual property.
1137-
1138-
<div class="example">
1139-
<pre>
1140-
p { font: 12pt/14pt sans-serif }
1141-
p { font: 80% sans-serif }
1142-
p { font: x-large/110% &quot;new century schoolbook&quot;, serif }
1143-
p { font: bold italic large Palatino, serif }
1144-
p { font: normal small-caps 120%/120% fantasy }
1145-
p { font: condensed oblique 12pt &quot;Helvetica Neue&quot;, serif; }
1146-
p { font: condensed oblique 25deg 753 12pt &quot;Helvetica Neue&quot;, serif; }
1095+
<pre class="propdef">
1096+
Name: font
1097+
Value: [ [ <<'font-style'>> ||
1098+
<<font-variant-css2>> ||
1099+
<<'font-weight'>> ||
1100+
<<font-stretch-css3>> ]? <<'font-size'>> [ / <<'line-height'>> ]? <<'font-family'>> ] |
1101+
caption | icon | menu | message-box | small-caption | status-bar
1102+
Initial: see individual properties
1103+
Applies to: all elements
1104+
Inherited: yes
1105+
Percentages: see individual properties
1106+
Computed value: see individual properties
1107+
Media: visual
1108+
Animatable: see individual properties
11471109
</pre>
11481110

1149-
In the second rule, the font size percentage value ("80%") refers
1150-
to the computed 'font-size' of the parent element. In the third rule, the line
1151-
height percentage ("110%") refers to the font size of the element
1152-
itself.
1153-
1154-
The first three rules do not specify the 'font-variant!!property' and
1155-
'font-weight!!property' explicitly, so these properties
1156-
receive their initial values (''font-variant/normal''). Notice that the font family
1157-
name ''"new century schoolbook"'', which contains spaces, is enclosed in
1158-
quotes. The fourth rule sets the 'font-weight!!property' to ''bold'',
1159-
the 'font-style!!property' to ''italic'', and implicitly sets
1160-
'font-variant!!property' to ''font-variant/normal''.
1161-
1162-
The fifth rule sets the 'font-variant!!property' (''small-caps''), the 'font-size!!property' (120% of the
1163-
parent's font size), the 'line-height!!property' (120% of the font size) and the
1164-
'font-family!!property' (''fantasy''). It follows that the keyword <css>normal</css>
1165-
applies to the two remaining properties: 'font-style!!property' and 'font-weight!!property'.
1166-
1167-
The sixth rule sets the 'font-style!!property', 'font-stretch!!property',
1168-
'font-size!!property', and 'font-family!!property', the other font
1169-
properties being set to their initial values.
1170-
1171-
The seventh rule sets 'font-style!!property' to ''oblique 25deg'',
1172-
'font-weight!!property' to ''753'', and 'font-stretch!!property' to ''condensed''.
1173-
Note that the ''25deg'' in this rule must be immediately following the "oblique" keyword.
1174-
</div>
1111+
The 'font!!property' property is,
1112+
except as described below,
1113+
a shorthand property for setting
1114+
'font-style!!property', 'font-variant!!property',
1115+
'font-weight!!property', 'font-stretch!!property',
1116+
'font-size!!property', 'line-height', 'font-family!!property'
1117+
at the same place in the stylesheet.
1118+
Values for the 'font-variant!!property' property can also be included
1119+
but only those supported in CSS 2.1;
1120+
none of the 'font-variant!!property' values added in
1121+
CSS Fonts Levels 3 or 4
1122+
can be used in the
1123+
'font!!property' shorthand:
1124+
1125+
<pre class="prod"><dfn id="font-variant-css21-values"><<font-variant-css2>></dfn>
1126+
= [normal | small-caps]</pre>
1127+
1128+
Values for the 'font-stretch!!property' property can also be included
1129+
but only those supported in CSS Fonts level 3,
1130+
none of the 'font-stretch!!property' values added in this specification
1131+
can be used in the 'font' shorthand:
1132+
1133+
<pre class="prod"><dfn id="font-stretch-css3-values"><<font-stretch-css3>></dfn>
1134+
= [normal | ultra-condensed | extra-condensed | condensed |
1135+
semi-condensed | semi-expanded | expanded | extra-expanded |
1136+
ultra-expanded]</pre>
1137+
1138+
The syntax of this property is based on a traditional
1139+
typographical shorthand notation
1140+
to set multiple properties related to fonts.
1141+
1142+
All subproperties of the 'font!!property' property are first reset
1143+
to their initial values,
1144+
including those listed above
1145+
plus 'font-size-adjust', 'font-kerning',
1146+
all subproperties of 'font-variant!!property',
1147+
'font-feature-settings!!property',
1148+
'font-language-override!!property',
1149+
'font-min-size',
1150+
'font-max-size',
1151+
'font-optical-sizing',
1152+
'font-variation-settings!!property',
1153+
and 'font-palette'.
1154+
Then, those properties that are given explicit values
1155+
in the 'font!!property' shorthand
1156+
are set to those values.
1157+
For a definition of allowed and initial values,
1158+
see the previously defined properties.
1159+
For reasons of backwards compatibility,
1160+
it is not possible to set 'font-size-adjust'
1161+
to anything other than its initial value
1162+
using the 'font' shorthand property;
1163+
instead, use the individual property.
11751164

1176-
Since the 'font-stretch!!property' property was not defined in CSS 2.1,
1177-
when using 'font-stretch!!property' values within 'font' rules,
1178-
authors should include a extra version compatible with older user agents:
1165+
<div class="example">
1166+
<pre>
1167+
p { font: 12pt/14pt sans-serif }
1168+
p { font: 80% sans-serif }
1169+
p { font: x-large/110% &quot;new century schoolbook&quot;, serif }
1170+
p { font: bold italic large Palatino, serif }
1171+
p { font: normal small-caps 120%/120% fantasy }
1172+
p { font: condensed oblique 12pt &quot;Helvetica Neue&quot;, serif; }
1173+
p { font: condensed oblique 25deg 753 12pt &quot;Helvetica Neue&quot;, serif; }
1174+
</pre>
11791175

1180-
<pre>
1181-
p {
1182-
font: 80% sans-serif; /* for older user agents */
1183-
font: condensed 80% sans-serif;
1184-
}
1185-
</pre>
1176+
In the second rule, the font size percentage value ("80%")
1177+
refers to the computed 'font-size' of the parent element.
1178+
In the third rule, the line height percentage ("110%")
1179+
refers to the font size of the element itself.
1180+
1181+
The first three rules do not specify
1182+
the 'font-variant!!property' and
1183+
'font-weight!!property' explicitly,
1184+
so these properties
1185+
receive their initial values (''font-variant/normal'').
1186+
Notice that the font family name ''"new century schoolbook"'',
1187+
which contains spaces,
1188+
is enclosed in quotes.
1189+
The fourth rule sets the 'font-weight!!property' to ''bold'',
1190+
the 'font-style!!property' to ''italic'',
1191+
and implicitly sets 'font-variant!!property' to ''font-variant/normal''.
1192+
1193+
The fifth rule sets the 'font-variant!!property' (''small-caps''),
1194+
the 'font-size!!property' (120% of the parent's font size),
1195+
the 'line-height!!property' (120% of the font size) and
1196+
the 'font-family!!property' (''fantasy'').
1197+
It follows that the keyword <css>normal</css>
1198+
applies to the two remaining properties:
1199+
'font-style!!property' and 'font-weight!!property'.
1200+
1201+
The sixth rule sets the 'font-style!!property',
1202+
'font-stretch!!property',
1203+
'font-size!!property', and
1204+
'font-family!!property',
1205+
the other font properties being set to their initial values.
1206+
1207+
The seventh rule sets 'font-style!!property' to ''oblique 25deg'',
1208+
'font-weight!!property' to ''753'', and
1209+
'font-stretch!!property' to ''condensed''.
1210+
Note that the ''25deg'' in this rule must be
1211+
immediately following the "oblique" keyword.
1212+
</div>
11861213

1187-
The following values refer to system fonts:
1188-
1189-
<dl dfn-type=value dfn-for=font>
1190-
<dt><dfn>caption</dfn>
1191-
<dd>The font used for captioned controls (e.g., buttons, drop-downs, etc.).
1192-
<dt><dfn>icon</dfn>
1193-
<dd>The font used to label icons.
1194-
<dt><dfn>menu</dfn>
1195-
<dd>The font used in menus (e.g., dropdown menus and menu lists).
1196-
<dt><dfn>message-box</dfn>
1197-
<dd>The font used in dialog boxes.
1198-
<dt><dfn>small-caption</dfn>
1199-
<dd>The font used for labeling small controls.
1200-
<dt><dfn>status-bar</dfn>
1201-
<dd>The font used in window status bars.
1202-
</dl>
1214+
Since the 'font-stretch!!property' property was not defined in CSS 2.1,
1215+
when using 'font-stretch!!property' values within 'font' rules,
1216+
authors should include a extra version compatible with older user agents:
12031217

1204-
System fonts can only be set as a whole; that is, the font
1205-
family, size, weight, style, etc. are all set at the same time.
1206-
These values can then be altered individually if desired. If no
1207-
font with the indicated characteristics exists on a given platform,
1208-
the user agent should either intelligently substitute (e.g., a smaller
1209-
version of the ''caption'' font might be used for the ''small-caption''
1210-
font), or substitute a user agent default font. As for regular fonts,
1211-
if, for a system font, any of the individual properties are not part
1212-
of the operating system's available user preferences, those properties
1213-
should be set to their initial values.
1214-
1215-
That is why this property is "almost" a shorthand property: system
1216-
fonts can only be specified with this property, not with
1217-
'font-family!!property' itself, so 'font!!property'
1218-
allows authors to do more than the
1219-
sum of its subproperties. However, the individual properties such as
1220-
'font-weight!!property' are still given values
1221-
taken from the system font, which can be independently varied.
1222-
1223-
Note that the keywords used for the system fonts listed above are
1224-
only treated as keywords when they occur in the initial position, in
1225-
other positions the same string is treated as part of the font family
1226-
name:
1218+
<pre>
1219+
p {
1220+
font: 80% sans-serif; /* for older user agents */
1221+
font: condensed 80% sans-serif;
1222+
}
1223+
</pre>
12271224

1228-
<pre>
1229-
font: menu; /* use the font settings for system menus */
1230-
font: large menu; /* use a font family named "menu" */
1231-
</pre>
1225+
The following values refer to system fonts:
1226+
1227+
<dl dfn-type=value dfn-for=font>
1228+
<dt><dfn>caption</dfn>
1229+
<dd>The font used for captioned controls (e.g., buttons, drop-downs, etc.).
1230+
<dt><dfn>icon</dfn>
1231+
<dd>The font used to label icons.
1232+
<dt><dfn>menu</dfn>
1233+
<dd>The font used in menus (e.g., dropdown menus and menu lists).
1234+
<dt><dfn>message-box</dfn>
1235+
<dd>The font used in dialog boxes.
1236+
<dt><dfn>small-caption</dfn>
1237+
<dd>The font used for labeling small controls.
1238+
<dt><dfn>status-bar</dfn>
1239+
<dd>The font used in window status bars.
1240+
</dl>
12321241

1233-
<div class="example">
1242+
System fonts can only be set as a whole;
1243+
that is, the font family, size, weight, style, etc.
1244+
are all set at the same time.
1245+
These values can then be altered individually if desired.
1246+
If no font with the indicated characteristics exists
1247+
on a given platform,
1248+
the user agent should either intelligently substitute
1249+
(e.g., a smaller version of the ''caption'' font might be used
1250+
for the ''small-caption'' font),
1251+
or substitute a user agent default font.
1252+
As for regular fonts,
1253+
if, for a system font, any of the individual properties
1254+
are not part of the operating system's available user preferences,
1255+
those properties
1256+
should be set to their initial values.
1257+
1258+
That is why this property is "almost" a shorthand property:
1259+
system fonts can only be specified with this property,
1260+
not with 'font-family!!property' itself,
1261+
so 'font!!property'
1262+
allows authors to do more than the
1263+
sum of its subproperties.
1264+
However, the individual properties
1265+
such as 'font-weight!!property'
1266+
are still given values
1267+
taken from the system font,
1268+
which can be independently varied.
1269+
1270+
Note that the keywords used for the system fonts listed above
1271+
are only treated as keywords
1272+
when they occur in the initial position,
1273+
in other positions the same string is treated
1274+
as part of the font family name:
12341275

12351276
<pre>
1236-
button { font: 300 italic 1.3em/1.7em &quot;FB Armada&quot;, sans-serif }
1237-
button p { font: menu }
1238-
button p em { font-weight: bolder }
1277+
font: menu; /* use the font settings for system menus */
1278+
font: large menu; /* use a font family named "menu" */
12391279
</pre>
12401280

1241-
If the font used for dropdown menus on a particular system
1242-
happened to be, for example, 9-point Charcoal, with a weight of 600, then P
1243-
elements that were descendants of BUTTON would be displayed as if
1244-
this rule were in effect:
1281+
<div class="example">
12451282

1246-
<pre>button p { font: 600 9pt Charcoal }</pre>
1283+
<pre>
1284+
button { font: 300 italic 1.3em/1.7em &quot;FB Armada&quot;, sans-serif }
1285+
button p { font: menu }
1286+
button p em { font-weight: bolder }
1287+
</pre>
12471288

1248-
Because the 'font!!property' shorthand resets to its initial value
1249-
any property not explicitly given a value, this has the same effect as
1250-
this declaration:
1289+
If the font used for dropdown menus
1290+
on a particular system
1291+
happened to be, for example,
1292+
9-point Charcoal, with a weight of 600,
1293+
then P elements that were descendants of BUTTON
1294+
would be displayed as if
1295+
this rule were in effect:
12511296

1252-
<pre>
1253-
button p {
1254-
font-style: normal;
1255-
font-variant: normal;
1256-
font-weight: 600;
1257-
font-size: 9pt;
1258-
line-height: normal;
1259-
font-family: Charcoal
1260-
}
1261-
</pre>
1262-
</div>
1297+
<pre>button p { font: 600 9pt Charcoal }</pre>
1298+
1299+
Because the 'font!!property' shorthand
1300+
resets to its initial value
1301+
any property not explicitly given a value,
1302+
this has the same effect as
1303+
this declaration:
1304+
1305+
<pre>
1306+
button p {
1307+
font-style: normal;
1308+
font-variant: normal;
1309+
font-weight: 600;
1310+
font-size: 9pt;
1311+
line-height: normal;
1312+
font-family: Charcoal
1313+
}
1314+
</pre>
1315+
</div>
12631316

12641317
<h3 id="font-synthesis-prop">
12651318
Controlling synthetic faces: the 'font-synthesis' property</h3>

0 commit comments

Comments
 (0)