-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathOverview.bs
3684 lines (3031 loc) · 156 KB
/
Overview.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<pre class='metadata'>
Title: CSS Fonts Module Level 4
Shortname: css-fonts
Level: 4
Status: ED
Work Status: Exploring
Group: CSSWG
ED: https://drafts.csswg.org/css-fonts-4/
TR: https://www.w3.org/TR/css-fonts-4/
Editor: John Daggett, Invited Expert, https://twitter.com/nattokirai, w3cid 41498
Editor: Myles C. Maxfield, Apple Inc., mmaxfield@apple.com, w3cid 77180
Abstract: This specification defines modifications to the existing <a href="https://drafts.csswg.org/css-fonts-3/">CSS Fonts 3</a> specification along with additional experimental features.
At Risk: Synthesis of the 'font-variant-position' property
Ignored Terms: font-palette, <named-palette-color>
</pre>
<pre class="link-defaults">
spec:css-color-4; type:property; text:color
spec:css22; type:value; for:/; text:block
spec:css-fonts-3;
type:descriptor; for:@font-face;
text:unicode-range
type:property; for:/;
text:font-kerning
</pre>
Advisement: This document contains ideas and
experiments that might or might not end up in the final version of a CSS
Fonts specification. Implementors are encouraged to ask about the status
of a particular feature listed here on the <code>www-style</code>
mailing list.
<h2 id="introduction">
Introduction</h2>
The CSS3 Fonts specification ([[!CSS-FONTS-3]]) describes the basic
controls CSS provides for selecting and using fonts within documents.
The ideas here are additions or modifications to the properties and
rules defined in CSS3 Fonts.
Issue: Please note that OpenType/TrueType variable font support
is still in intial stages of specification and implementation. Please
comment on any bugs in this spec at <a href="https://github.com/w3c/csswg-drafts/issues">
https://github.com/w3c/csswg-drafts/issues</a>. Also, please note that this
spec is incomplete and only includes some of the text from <a href="https://www.w3.org/TR/css-fonts-3/">
https://www.w3.org/TR/css-fonts-3/</a>.
<h2 id="basic-font-props">
Basic Font Properties</h2>
The particular font face used to render a character is determined by
the font family and other font properties that apply to a given element.
This structure allows settings to be varied independent of each
other.
<h3 id="font-family-prop">
Font family: the 'font-family!!property' property</h3>
<pre class="propdef">
Name: font-family
Value: [ <<family-name>> | <<generic-family>> ] #
Initial: depends on user agent
Applies to: all elements
Inherited: yes
Percentages: n/a
Computed value: as specified
Media: visual
Animatable: no
</pre>
This property specifies a prioritized list of font family names or
generic family names. A font family defines a set of faces that vary
in weight, width or slope. CSS uses the combination of a family name
with other style attributes to select an individual face. Using this
selection mechanism, rather than selecting a face via the style name
as is often done in design applications, allows some degree of
regularity in textual display when fallback occurs.
Note: Designers should note that the CSS definition of font
attributes used for selection are explicitly not intended to define a
font taxonomy. A type designer's idea of a family can often extend to
a set of faces that vary along axes other than just the standard axes
of weight, width and slope. A family can extend to include both a set
of serif faces and a set of sans-serif faces or vary along axes that
are unique to that family. The CSS font selection mechanism merely
provides a way to determine the “closest” substitute when
substitution is necessary.
Unlike other CSS properties, component values are a comma-separated
list indicating alternatives. A user agent iterates through the list
of family names until it matches an available font that contains a
glyph for the character to be rendered. This allows for differences
in available fonts across platforms and for differences in the range
of characters supported by individual fonts.
A font family name only specifies a name given to a set of font
faces, it does not specify an individual face. For example, given the availability
of the fonts below, Futura would match but Futura Medium would not:
<figure>
<img alt="family and face names" src="images/familyvsfacename.png">
<figcaption>Family and individual face names</figcaption>
</figure>
Consider the example below:
<div class="example">
<pre>
body {
font-family: Helvetica, Verdana, sans-serif;
}
</pre>
If Helvetica is available it will be used when rendering. If
neither Helvetica nor Verdana is present, then the user-agent-defined
sans serif font will be used.
</div>
There are two types of font family names:
<dl>
<dt><dfn id="family-name-value"><<family-name>></dfn>
<dd>
The name of a font family of choice such as Helvetica or Verdana in the previous example.
<dt><dfn id="generic-family-value"><<generic-family>></dfn>
<dd>
The following generic family keywords are defined: ''serif'', ''sans-serif'', ''cursive'',
''fantasy'', and ''monospace''. These keywords can be used as a general fallback mechanism
when an author's desired font choices are not available. As keywords, they must not
be quoted. Authors are encouraged to append a generic font family as a last alternative for
improved robustness.
</dl>
Font family names other than generic families must either be given quoted as <a
href="https://www.w3.org/TR/CSS21/syndata.html#strings">strings,</a>
or unquoted as a sequence of one or more
<a href="https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">identifiers.</a>
This means most punctuation characters and digits at the start of
each token must be escaped in unquoted font family names.
To illustrate this, the following declarations are invalid:
<pre>
font-family: Red/Black, sans-serif;
font-family: "Lucida" Grande, sans-serif;
font-family: Ahem!, sans-serif;
font-family: test@foo, sans-serif;
font-family: #POUND, sans-serif;
font-family: Hawaii 5-0, sans-serif;
</pre>
If a sequence of identifiers is given as a font family name,
the computed value is the name converted to a string by joining
all the identifiers in the sequence by single spaces.
To avoid mistakes in escaping, it is recommended to quote font
family names that contain white space, digits, or punctuation
characters other than hyphens:
<pre>
body { font-family: "New Century Schoolbook", serif }
<BODY STYLE="font-family: '21st Century', fantasy">
</pre>
Font family <em>names</em> that happen to be the same as keyword
value (''inherit'', ''serif'', etc.) must be quoted to prevent confusion
with the keywords with the same names. UAs must not consider these
keywords as matching the <var><family-name></var> type. This
applies to any keyword across all of CSS.
The precise way a set of fonts are grouped into font families
varies depending upon the platform font management API's. The
Windows GDI API only allows four faces to be grouped into a family
while the DirectWrite API, Core Text API, and other platforms support
font families with a variety of weights, widths and slopes (see <a
href="#platform-props-to-css">Appendix A</a> for more details).
Some font formats allow fonts to carry multiple localizations
of the family name. User agents must recognize and correctly
match all of these names independent of the underlying platform
localization, system API used or document encoding:
<figure>
<img alt="examples of localized family names" src="images/localizedfamilynames.png" >
<figcaption>Localized family names</figcaption>
</figure>
The details of localized font family name matching and the
corresponding issues of case sensitivity are described below in the
<a href="#font-family-casing">font matching</a> section.
<h4 id="generic-font-families">
Generic font families</h4>
All nine generic font families must always result in at least
one matched font face, for all CSS implementations. However, the
generics may be composite faces (with different typefaces based
on such things as the Unicode range of the character, the language of the containing
element, user preferences and system settings, among others). They are also
not guaranteed to always be different from each other.
User agents should provide reasonable default choices for the
generic font families, which express the characteristics of each
family as well as possible, within the limits allowed by the underlying
technology. User agents are encouraged to allow users to select
alternative choices for the generic fonts.
<h5 id="serif-def" class="no-num no-toc">
<dfn>serif</dfn></h5>
Serif fonts represent the formal text style for a script.
This often means but is not limited to glyphs that have finishing
strokes, flared or tapering ends, or have actual serifed endings
(including slab serifs). Serif fonts are typically
proportionately-spaced. They often display a greater variation between
thick and thin strokes than fonts from the ''sans-serif'' generic font
family. CSS uses the term "serif" to apply to a font for any script,
although other names might be more familiar for particular scripts, such
as Mincho (Japanese), Sung or Song (Chinese), Batang (Korean).
For Arabic, the Naskh style would correspond to ''serif'' more due to
its typographic role rather than its actual design style.
Any font that is so described may be used to represent the
generic ''serif'' family.
<figure>
<img alt="sample serif fonts" src="images/serifexamples.png" >
<figcaption>Sample serif fonts</figcaption>
</figure>
<h5 id="sans-serif-def" class="no-num no-toc">
<dfn>sans-serif</dfn></h5>
Glyphs in sans-serif fonts,
as the term is used in CSS,
are generally low contrast
(vertical and horizontal stems have the close to the same thickness)
and have stroke endings that are plain--
without any flaring, cross stroke, or other ornamentation.
Sans-serif fonts are typically proportionately-spaced.
They often have little variation between thick and thin strokes,
compared to fonts from the ''serif'' family.
CSS uses the term "sans-serif" to apply to a font for any script,
although other names might be more familiar for particular scripts,
such as Gothic (Japanese), Hei (Chinese), or Gulim (Korean).
Any font that is so described may be used to represent the generic ''sans-serif''family.
<figure>
<img alt="sample sans-serif fonts" src="images/sansserifexamples.png" >
<figcaption>Sample sans-serif fonts</figcaption>
</figure>
<h5 id="cursive-def" class="no-num no-toc">
<dfn>cursive</dfn></h5>
Glyphs in cursive fonts generally use a more informal script style,
and the result looks more like handwritten pen or brush writing than
printed letterwork. CSS uses the term "cursive" to apply to a font for
any script, although other names such as Chancery, Brush, Swing and
Script are also used in font names.
<figure>
<img alt="sample cursive fonts" src="images/cursiveexamples.png" >
<figcaption>Sample cursive fonts</figcaption>
</figure>
<h5 id="fantasy-def" class="no-num no-toc">
<dfn>fantasy</dfn></h5>
Fantasy fonts are primarily decorative or expressive fonts that contain decorative or
expressive representations of characters.
These do not include Pi or Picture fonts which do not represent actual characters.
<figure>
<img alt="sample fantasy fonts" src="images/fantasyexamples.png" >
<figcaption>Sample fantasy fonts</figcaption>
</figure>
<h5 id="monospace-def" class="no-num no-toc">
<dfn>monospace</dfn></h5>
The sole criterion of a monospace font is that all glyphs have the same fixed width. This is often used
to render samples of computer code.
<figure>
<img alt="sample monospace fonts" src="images/monospaceexamples.png" >
<figcaption>Sample monospace fonts</figcaption>
</figure>
<h5 id="system-ui-def" class="no-num no-toc">
<dfn>system-ui</dfn></h5>
This generic font family is intended to let text render with the default user interface font on the platform on which the UA is running. A cross-platform UA should use different fonts on its different supported platforms. The purpose of ''system-ui'' is to allow web content to integrate with the look and feel of a native app. On platforms which have a collection of system user interface fonts (e.g. for different languages), user agents may treat ''system-ui'' as a virtual font which encompasses all the platform user interface fonts. However, if this is done, the details of the virtual font must not be visible or detectable.
<div class="example">
<pre>
<div id="system-text" style="font-family: system-ui"></div>
...
window.getComputedStyle(document.getElementById("system-text")).getPropertyValue("font-family");
</pre>
The script above should not have any knowledge if ''system-ui'' is expanded to include a collection of system user interface fonts. In particular, the above script should yield a result of "system-ui" on every platform.
</div>
Issue: Add ''system-ui'' fingerprinting issue to Security and Privacy Considerations section
per <a href="https://lists.w3.org/Archives/Public/www-style/2015Aug/0051.html">discussion</a>.
<h5 id="emoji-def" class="no-num no-toc">
<dfn>emoji</dfn></h5>
This font family is intended for use with emoji characters.
<h5 id="math-def" class="no-num no-toc">
<dfn>math</dfn></h5>
This font family is intended for use with mathematical expressions.
<h5 id="fangsong-def" class="no-num no-toc">
<dfn>fangsong</dfn></h5>
This font family is used for fang song typefaces in Chinese.
<h3 id="font-weight-prop">Font weight: the 'font-weight!!property' property</h3>
<pre class="propdef">
Name: font-weight
Value: <<font-weight-absolute>> | bolder | lighter
Initial: normal
Applies to: all elements
Inherited: yes
Percentages: n/a
Computed value: numeric weight value (see description)
Media: visual
Animatable: As <<number>>
</pre>
The 'font-weight!!property' property specifies the weight of glyphs in the font, their degree of blackness or stroke thickness.
This property accepts values of the following:
<pre class="prod"><dfn id="font-weight-absolute-values"><font-weight-absolute></dfn> = [normal | bold | <<number>>]</pre>
Values have the following meanings:
<dl dfn-for=font-weight dfn-type=value>
<dt id="font-weight-numeric-values"><dfn><<number>></dfn>
<dd>
These values form an ordered sequence, where each number indicates a weight that is
at least as dark as its predecessor. Only values greater than or equal to 1, and less than or equal to 1000, are valid, and all other values are treated as parse errors. Certain numeric values correspond to the commonly used weight names below (Note that a font might internally provide its own mappings, but those mappings within the font are disregarded):
<ul>
<li>100 - Thin
<li>200 - Extra Light (Ultra Light)
<li>300 - Light
<li>400 - Normal
<li>500 - Medium
<li>600 - Semi Bold (Demi Bold)
<li>700 - Bold
<li>800 - Extra Bold (Ultra Bold)
<li>900 - Black (Heavy)
</ul>
<dt><dfn>normal</dfn>
<dd>
Same as ''400''.
<dt><dfn>bold</dfn>
<dd>
Same as ''700''.
<dt><dfn>bolder</dfn>
<dd>
Specifies a bolder weight than the inherited value.
<dt><dfn>lighter</dfn>
<dd>
Specifies a lighter weight than the inherited value.
</dl>
Font formats that use a scale other than a nine-step scale should map
their scale onto the CSS scale so that 400 roughly corresponds with a
face that would be labeled as Regular, Book, Roman and 700 roughly
matches a face that would be labeled as Bold. Or weights may be
inferred from the style names, ones that correspond roughly with the
scale above. The scale is relative, so a face with a larger weight value
must never appear lighter. If style names are used to infer weights,
care should be taken to handle variations in style names across locales.
Quite often there are only a few weights available for a particular
font family. When a weight is specified for which no face exists, a
face with a nearby weight is used. In general, bold weights map to faces
with heavier weights and light weights map to faces with lighter weights
(see the <a href="#font-matching-algorithm">font matching section
below</a> for a precise definition). The examples here illustrate which
face is used for different weights, grey indicates a face for that
weight does not exist so a face with a nearby weight is used:
<figure>
<img alt="weight mappings for a family with 400, 700 and 900 weights" src="images/optimaweights.png" >
<figcaption>Weight mappings for a font family with 400, 700 and 900 weight faces</figcaption>
</figure>
<figure>
<img alt="weight mappings for a family with 300, 600 weights" src="images/hiraginoweights.png" >
<figcaption>Weight mappings for a font family with 300 and 600 weight faces</figcaption>
</figure>
Most user agents model a font as having a particular weight which often corresponds to one of the numbers in the nine-step scale mentioned <a href="#font-weight-numeric-values">above</a>.
While this is true of most fonts, some fonts might be configurable so as to
support a range of weights. In this situation, the user agent uses a face
with a weight as close as possible to the weight requested (see the
<a href="#font-matching-algorithm">font matching section below</a> for the
precise algorithm). In particular, a user agent using a font which supports
a range of weights should behave the same as if a font is present at each
individual weight in the range. For TrueType / OpenType fonts which use variations, the "wght"
variation is used to implement varying weights. Fractional weights are
valid.
Although the practice is not well-loved by typographers, bold faces are often
synthesized by user agents for faces that lack actual bold faces. For
the purposes of style matching, these faces must be treated as if they
exist within the family. Authors can explicitly avoid this behavior
by using the 'font-synthesis' property.
Specified values of ''bolder'' and ''lighter'' indicate weights
relative to the weight of the parent element. The computed weight is
calculated based on the inherited 'font-weight!!property' value using the chart
below.
<table id="bolderlighter" class="data" summary="Bolder/lighter mappings">
<thead>
<tr>
<th>Inherited value
<th>bolder
<th>lighter
<tbody>
<tr><th>- 99<td>400<td>No change
<tr><th>100 - 349<td>400<td>100
<tr><th>350 - 549<td>700<td>100
<tr><th>550 - 749<td>900<td>400
<tr><th>750 - 899<td>900<td>700
<tr><th>900 -<td>No change<td>700
</table>
The table above is equivalent to selecting the next relative bolder or lighter face,
given a font family containing normal and bold faces along with a thin and a heavy face.
Authors who desire finer control over the exact weight values used for a given element
can use numerical values instead of relative weights.
Note: There is a small behavior change between [[CSS-FONTS-3]] and this specification with the animation of the 'font-size' property.
Previously, interpolated values of font-weight were rounded to their closest multiple of 100, and the font-matching algorithm was run on these
rounded values. In this specification, the font-matching algorithm is able to accept any value, so no rounding occurs. The small behavior change is due to the discontinuous nature of the font-matching algorithm.
<h3 id="font-stretch-prop">
Font width: the 'font-stretch!!property' property</h3>
<pre class="propdef">
Name: font-stretch
Value: <<font-stretch-absolute>>
Initial: normal
Applies to: all elements
Inherited: yes
Percentages: Not resolved.
Computed value: As specified
Media: visual
Animatable: As <<number>>
</pre>
The 'font-stretch!!property' property selects a normal,
condensed, or expanded face from a font family.
This property accepts values of the following:
<pre class="prod"><dfn id="font-stretch-absolute-values"><font-stretch-absolute></dfn> = [normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | <<percentage>>]</pre>
Absolute keyword values are aliased to
have the following meaning (Note that a font might internally provide its own mappings, but those mappings within the font are disregarded):
<table id="stretchmappings" class="data" summary="font-stretch numeric mappings">
<thead>
<tr>
<th>Absolute keyword value
<th>Numeric value
<tbody>
<tr><th>ultra-condensed<th>50%
<tr><th>extra-condensed<th>62.5%
<tr><th>condensed<th>75%
<tr><th>semi-condensed<th>87.5%
<tr><th>normal<th>100%
<tr><th>semi-expanded<th>112.5%
<tr><th>expanded<th>125%
<tr><th>extra-expanded<th>150%
<tr><th>ultra-expanded<th>200%
</table>
Values less than 0% are not allowed and are treated as parse errors.
When a face does not exist
for a given width, values less than 100% map to a narrower face,
otherwise a wider face. Conversely, values greater than or equal to 100% map to a wider
face, otherwise a narrower face. Some fonts might support a range of stretch
values; if the requested stretch value is not available in the font, the
closest supported value should be used, using the same mapping rules (see the
<a href="#font-matching-algorithm">font matching section below</a> for the
precise algorithm). For TrueType / OpenType fonts which use variations, the "wdth"
variation is used to implement varying widths. The figure below shows how nine
font-stretch property settings affect font matching for font family
containing a variety of discrete widths. Grey indicates a width for which no
face exists and a different width is substituted:
<figure>
<img alt="width mappings for a family with condensed, normal and expanded faces" src="images/universwidths.png" >
<figcaption>Width mappings for a font family with condensed, normal and expanded width faces</figcaption>
</figure>
User Agents must not sythesize stretched faces for font families which lack actual stretched faces.
<h3 id="font-style-prop">
Font style: the 'font-style!!property' property</h3>
<pre class="propdef">
Name: font-style
Value: normal | italic | oblique <<angle>>?
Initial: normal
Applies to: all elements
Inherited: yes
Percentages: n/a
Computed value: As specified
Media: visual
Animatable: If both "from" and "to" values are "oblique", then yes, as an <<angle>>. Otherwise, no.
</pre>
The 'font-style!!property' property allows
italic or oblique faces to be selected. Italic forms are generally cursive in nature while oblique faces are
typically sloped versions of the regular face. Oblique faces can be simulated by artificially sloping the
glyphs of the regular face. Compare the artificially sloped renderings of Palatino "a" and Baskerville "N"
in grey with the actual italic versions:
<figure>
<img alt="artificial sloping vs. real italics" src="images/realvsfakeitalics.png" >
<figcaption>Artificial sloping versus real italics</figcaption>
</figure>
Values have the following meanings:
<dl dfn-for=font-style dfn-type=value>
<dt><dfn>normal</dfn>
<dd>
Matches against a face that is classified as a normal face, one that is neither italic or obliqued. This represents an oblique value of "0".
<dt><dfn>italic</dfn>
<dd>
Matches against a font that is labeled as an italic face, or an oblique face if one is not.
<dt><dfn>oblique <<angle>>?</dfn>
<dd>
Controls matching against an oblique face. The lack of a number represents an angle of "20deg". Values less than -90deg or values greater than 90deg are invalid and are treated as parse errors. (Note that a font might internally provide its own mapping for "oblique", but that mapping within the font is disregarded).
Matches against a font that is labeled as an oblique face, or an italic face if one is not.
</dl>
Some font families might contain only zero or one italic or oblique face, while yet other
families might contain multiple oblique faces with varying
angles. The font matching routine will select a font to use which
is closest to the requested angle. In general, for a requested angle greater
or equal to 20deg, larger angles are prefered; otherwise, smaller
angles are preferred (see the
<a href="#font-matching-algorithm">font matching section below</a> for
the precise algorithm). Fractional and negative values are accepted, but values
less than -90 as well as values greater than 90 are not
allowed and are treated as parse errors.
For TrueType / OpenType fonts which use variations, the "slnt"
variation is used to implement oblique values, and the "ital" variation with a value of "1"
is used to implement the italic values. The meaning of a
negative value for "oblique" is to slope the text in the opposite
direction.
If no italic or oblique face is available, oblique faces can be
synthesized by rendering non-obliqued faces with an artificial
obliquing operation. The use of these artificially obliqued faces
can be disabled using the 'font-synthesis' property. The details
of the obliquing operation are not explicitly defined.
For the purposes of font matching, User Agents may treat ''italic'' as a synonym for
''oblique''. For User Agents which treat these values distinctly, synthesis must not
be performed for ''italic''. All user agents may perform synthesis for ''oblique''.
Note: Authors should also be aware that synthesized
approaches might not be suitable for scripts like Cyrillic, where italic
forms are very different in shape. It is always better to use an actual
italic font rather than rely on a synthetic version.
<!-- resolution on the "undefined" nature of synthetics: https://www.w3.org/2013/06/06-css-minutes.html#item03 -->
Many scripts lack the tradition of mixing a cursive form within
text rendered with a normal face. Chinese, Japanese and Korean fonts
almost always lack italic or oblique faces. Fonts that support a
mixture of scripts will sometimes omit specific scripts such as Arabic
from the set of glyphs supported in the italic face. User agents
should be careful about making <a>character map</a> assumptions across
faces when implementing support for <em>installed font fallback</em>.
<h3 id="font-size-prop">
Font size: the 'font-size' property</h3>
<pre class="propdef">
Name: font-size
Value: <<absolute-size>> | <<relative-size>> | <<length-percentage>>
Initial: medium
Applies to: all elements
Inherited: yes
Percentages: refer to parent element's font size
Computed value: absolute length
Media: visual
Animatable: As <<length>>
</pre>
This property indicates the desired height of glyphs from the
font. For scalable fonts, the font-size is a scale factor applied to the EM unit
of the font. (Note that certain glyphs might bleed outside their EM box.) For
non-scalable fonts, the font-size is converted into absolute units and matched
against the declared font-size of the font, using the same absolute coordinate
space for both of the matched values.
Values have the following meanings:
<dl dfn-for=font-size dfn-type=value>
<dt><dfn><<absolute-size>></dfn>
<dd>
An <<absolute-size>> keyword refers to an entry
in a table of font sizes computed and kept by the user agent. Possible values
are:
<pre class=prod>[ xx-small | x-small | small | medium | large | x-large | xx-large ]</pre>
<dt><dfn><<relative-size>></dfn>
<dd>
A <<relative-size>> keyword is interpreted
relative to the table of font sizes and the computed 'font-size' of the
parent element. Possible values are:
<pre class=prod>[ larger | smaller ]</pre>
For example, if the parent element has a font size of
''medium'', a value of ''larger'' will make the font size of the
current element be ''large''. If the parent element's size is not
close to a table entry, the user agent is free to interpolate
between table entries or round off to the closest one. The user
agent might have to extrapolate table values if the numerical value
goes beyond the keywords.
<dt><dfn><<length-percentage>></dfn>
<dd>
A length value specifies an absolute font size
(independent of the user agent's font table).
Negative lengths are invalid.
A percentage value specifies an absolute font size relative
to the parent element's font size. Use of percentage values, or
values in ''em''s, leads to more robust and cascadable style sheets.
Negative percentages are invalid.
</dl>
The following table provides user agent guidelines for the
absolute-size scaling factor and their mapping to HTML heading and
absolute font-sizes. The ''medium'' value is used as the reference
middle value. The user agent may fine-tune these values for different
fonts or different types of display devices.
<table class="data">
<thead>
<th>CSS absolute-size values
<th>xx-small
<th>x-small
<th>small
<th>medium
<th>large
<th>x-large
<th>xx-large
<th>
<tbody>
<tr>
<th>scaling factor
<td>3/5
<td>3/4
<td>8/9
<td>1
<td>6/5
<td>3/2
<td>2/1
<td>3/1
<tr>
<th>HTML headings
<td>h6
<td>
<td>h5
<td>h4
<td>h3
<td>h2
<td>h1
<td>
<tr>
<th>HTML font sizes
<td>1
<td>
<td>2
<td>3
<td>4
<td>5
<td>6
<td>7
</table>
Note: To preserve readability, an UA applying
these guidelines should nevertheless avoid creating font-size resulting
in less than 9 device pixels per EM unit on a computer display.
Note: In CSS1, the suggested
scaling factor between adjacent indexes was 1.5 which user experience
proved to be too large. In CSS2, the suggested scaling factor for computer
screen between adjacent indexes was 1.2 which still created issues for the small
sizes. The new scaling factor varies between each index to provide a better
readability.
The actual value of this property might differ from the computed
value due a numerical value on 'font-size-adjust' and the
unavailability of certain font sizes.
The computed value of this property is affected by the computed value of 'font-min-size'
and 'font-max-size'.
Child elements inherit the computed 'font-size' value (otherwise, the
effect of 'font-size-adjust' would compound).
<div class="example">
<pre>
p { font-size: 12pt; }
blockquote { font-size: larger }
em { font-size: 150% }
em { font-size: 1.5em }
</pre>
</div>
<h3 id="font-min-max-size-prop">Minimum and maximum font size: the 'font-min-size' and 'font-max-size' properties</h3>
<pre class="propdef">
Name: font-min-size
Value: <<absolute-size>> | <<relative-size>> | <<length-percentage>>
Initial: 0
Applies to: all elements
Inherited: yes
Percentages: refer to parent element's font size
Computed value: absolute length
Media: visual
Animatable: As <<length>>
</pre>
<pre class="propdef">
Name: font-max-size
Value: <<absolute-size>> | <<relative-size>> | <<length-percentage>> | infinity
Initial: infinity
Applies to: all elements
Inherited: yes
Percentages: refer to parent element's font size
Computed value: absolute length
Media: visual
Animatable: As <<length>>
</pre>
These two properties allow a website or user to require an element's font size to be clamped within the range
supplied with these two properties. If the computed value 'font-size' is outside the bounds created by 'font-min-size'
and 'font-max-size', the use value of 'font-size' is clamped to the values specified in these two properties.
Some user agents provide a nonstandard mapping between the computed value of 'font-size' and the used value of 'font-size'.
The interaction of those nonstandard algorithms with 'font-min-size' or 'font-max-size' is explicitly undefined.
If the 'font-min-size' property is computed to be larger than the 'font-max-size' property, then the two properties are ignored.
Users with accessibility preferences can set this in a user-agent style sheet to force websites' text to become larger.
The computed value of these two properties affects the computed value of 'font-size'.
<h3 id="font-size-adjust-prop">
Relative sizing: the 'font-size-adjust' property</h3>
<pre class="propdef">
Name: font-size-adjust
Value: none | <<number>>
Initial: none
Applies to: all elements
Inherited: yes
Percentages: N/A
Computed value: as specified
Media: visual
Animatable: as <<number>>
</pre>
For any given font size, the apparent size and legibility of text
varies across fonts. For scripts such as Latin or Cyrillic that
distinguish between upper and lowercase letters, the relative height
of lowercase letters compared to their uppercase counterparts is a
determining factor of legibility. This is commonly referred to as the
<dfn>aspect value</dfn>.
Precisely defined, it is equal to the x-height of a font divided by
the font size.
In situations where font fallback occurs, fallback fonts might not
share the same aspect value as the desired font family and will thus
appear less readable. The 'font-size-adjust' property is a way to
preserve the readability of text when font fallback occurs. It does
this by adjusting the font-size so that the x-height is the same
regardless of the font used.
<div class="example">
The style defined below defines Verdana as the desired font family, but if Verdana is not available Futura or Times
will be used.
<pre>
p {
font-family: Verdana, Futura, Times;
}
<p>Lorem ipsum dolor sit amet, ...</p>
</pre>
Verdana has a relatively high aspect value, lowercase letters are relatively tall compared to uppercase
letters, so at small sizes text appears legible. Times has a lower aspect value and so if fallback occurs,
the text will be less legible at small sizes than Verdana.
</div>
How text rendered in each of these fonts compares is shown below, the columns show text rendered in Verdana, Futura and Times.
The same font-size value is used across cells
within each row and red lines are included to show the differences in x-height. In the upper half each row is rendered in the same font-size value. The same is true
for the lower half but in this half the 'font-size-adjust' property is also set so that the actual font size is adjusted
to preserve the x-height across each row. Note how small text remains relatively legible across each row in the lower half.
<figure>
<img alt="text with and without 'font-size-adjust'" src="images/fontsizeadjust.png" >
<figcaption>Text with and without the use of 'font-size-adjust'</figcaption>
</figure>
This property allows authors to specify an <a>aspect value</a> for an element that
will effectively preserve the x-height of the first choice font, whether it is substituted
or not. Values have the following meanings:
<dl dfn-type=value dfn-for=font-size-adjust>
<dt><dfn id="font-size-adjust-none-value">none</dfn>
<dd>
Do not preserve the font's x-height.
<dt><dfn id="aspect-ratio-value"><var><number></var></dfn>
<dd>
Specifies the <a>aspect value</a> used in the calculation below to calculate the adjusted
font size:
<pre>c = ( a / a' ) s</pre>
where:
<pre>
s = font-size value
a = <a>aspect value</a> as specified by the 'font-size-adjust' property
a' = <a>aspect value</a> of actual font
c = adjusted font-size to use
</pre>
Negative values are invalid.
This value applies to any font that is selected but in typical usage it should be based
on the <a>aspect value</a> of the first font in the font-family list. If this is specified accurately,
the <code>(a/a')</code> term in the formula above is effectively 1 for the first font and no adjustment occurs.
If the value is specified inaccurately, text rendered using the first font in the family
list will display differently in older user agents that don't support 'font-size-adjust'.
</dl>
The value of 'font-size-adjust' affects the used value of 'font-size' but
does not affect the computed value. It affects the size of relative units
that are based on font metrics of the <a>first available font</a> such
as <code>ex</code> and <code>ch</code> but does not affect the size of
<code>em</code> units. Since numeric values of
<a href="https://www.w3.org/TR/CSS2/visudet.html#propdef-line-height">'line-height'</a>
refer to the computed size of 'font-size', 'font-size-adjust' does not affect the used value of
<a href="https://www.w3.org/TR/CSS2/visudet.html#propdef-line-height">'line-height'</a>.
Note: In CSS, authors often specify
<a href="https://www.w3.org/TR/CSS2/visudet.html#propdef-line-height">'line-height'</a>
as a multiple of the 'font-size'. Since the 'font-size-adjust'
property affects the used value of 'font-size', authors should take
care setting the line height when 'font-size-adjust' is used. Setting
the line height too tightly can result in overlapping lines of text
in this situation.
Authors can calculate the
<a>aspect value</a> for a given font by comparing spans with the same content but
different 'font-size-adjust' properties. If the same font-size is used, the spans will match when the 'font-size-adjust'
value is accurate for the given font.
<div class="example">
Two spans with borders are used to determine the <a>aspect value</a> of a font. The 'font-size' is the same for both spans but the
'font-size-adjust' property is specified only for the right span. Starting with a value of 0.5, the aspect
value can be adjusted until the borders around the two letters line up.
<pre>
p {
font-family: Futura;
font-size: 500px;
}
span {
border: solid 1px red;
}
.adjust {
font-size-adjust: 0.5;
}
<p><span>b</span><span class="adjust">b</span></p>
</pre>
<figure>
<img alt="Futura with an aspect value of 0.5" src="images/beforefontsizeadjust.png" >
<figcaption>Futura with an <a>aspect value</a> of 0.5</figcaption>
</figure>
The box on the right is a bit bigger than the one on the left, so the <a>aspect value</a> of this font is something less than 0.5.
Adjust the value until the boxes align.
</div>
<h3 id="font-prop">
Shorthand font property: the 'font' property</h3>
<pre class="propdef">
Name: font
Value: [ [ <<'font-style'>> || <<font-variant-css21>> || <<'font-weight'>> || <<font-stretch-css3>> ]? <<'font-size'>> [ / <<'line-height'>> ]? <<'font-family'>> ] | caption | icon | menu | message-box | small-caption | status-bar
Initial: see individual properties
Applies to: all elements
Inherited: yes
Percentages: see individual properties
Computed value: see individual properties
Media: visual
Animatable: see individual properties
</pre>
The 'font!!property' property is,
except as described below,
a shorthand property for setting
'font-style!!property', 'font-variant!!property', 'font-weight!!property', 'font-stretch!!property',
'font-size!!property', 'line-height', 'font-family!!property'
at the same place in the stylesheet.
Values for the 'font-variant!!property' property can also be included
but only those supported in CSS 2.1;
none of the 'font-variant!!property' values added in this specification can be used in the
'font!!property' shorthand:
<pre class="prod"><dfn id="font-variant-css21-values"><font-variant-css21></dfn> = [normal | small-caps]</pre>
Values for the 'font-stretch!!property' property can also be included but only those supported in
CSS Fonts level 3, none of the 'font-stretch!!property' values added in this specification can be used in the 'font' shorthand:
<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>
The syntax of this property is based on a traditional typographical
shorthand notation to set multiple properties related to fonts.
All subproperties of the 'font!!property' property are first reset to their initial values,
including those listed above plus 'font-size-adjust', 'font-kerning', all subproperties of 'font-variant!!property', 'font-feature-settings!!property',
'font-language-override', 'font-min-size', 'font-max-size', 'font-optical-sizing', 'font-variation-settings!!property', and 'font-palette'.
Then, those properties that are given explicit values in the 'font!!property'
shorthand are set to those values. For a definition of allowed and
initial values, see the previously defined properties. For reasons of
backwards compatibility, it is not possible to set 'font-size-adjust'
to anything other than its initial value using the 'font'
shorthand property; instead, use the individual property.
<div class="example">
<pre>
p { font: 12pt/14pt sans-serif }
p { font: 80% sans-serif }
p { font: x-large/110% "new century schoolbook", serif }
p { font: bold italic large Palatino, serif }
p { font: normal small-caps 120%/120% fantasy }
p { font: condensed oblique 12pt "Helvetica Neue", serif; }
p { font: condensed oblique 25deg 753 12pt "Helvetica Neue", serif; }
</pre>
In the second rule, the font size percentage value ("80%") refers
to the computed 'font-size' of the parent element. In the third rule, the line
height percentage ("110%") refers to the font size of the element
itself.
The first three rules do not specify the 'font-variant!!property' and
'font-weight!!property' explicitly, so these properties
receive their initial values (''font-variant/normal''). Notice that the font family
name ''"new century schoolbook"'', which contains spaces, is enclosed in
quotes. The fourth rule sets the 'font-weight!!property' to ''bold'',
the 'font-style!!property' to ''italic'', and implicitly sets
'font-variant!!property' to ''font-variant/normal''.
The fifth rule sets the 'font-variant!!property' (''small-caps''), the 'font-size!!property' (120% of the