-
Notifications
You must be signed in to change notification settings - Fork 671
/
Overview.bs
8700 lines (7730 loc) · 305 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 Text Module Level 3
Shortname: css-text
Level: 3
Status: ED
Work Status: Testing
Group: csswg
ED: https://drafts.csswg.org/css-text-3/
TR: https://www.w3.org/TR/css-text-3/
Previous version: https://www.w3.org/TR/2023/CRD-css-text-3-20230903/
Test Suite: http://test.csswg.org/suites/css3-text/nightly-unstable/
!Test Coverage Analysis: <a href="https://drafts.csswg.org/css-text-3/test-coverage">https://drafts.csswg.org/css-text-3/test-coverage</a>
Implementation Report: https://test.csswg.org/harness/results/css-text-3_dev/grouped/
Editor: Elika J. Etemad / fantasai, Apple, http://fantasai.inkedblade.net/contact, w3cid 35400
Editor: Koji Ishii, Invited Expert, [email protected], w3cid 45369
Editor: Florian Rivoal, Invited Expert, https://florian.rivoal.net, w3cid 43241
Abstract: This CSS module defines properties for text manipulation and specifies their processing model. It covers line breaking, justification and alignment, white space handling, and text transformation.
At Risk: the ''full-width'' value of 'text-transform'
At Risk: the ''full-size-kana'' value of 'text-transform'
At Risk: the <length> values of the 'tab-size' property
At Risk: the 'text-justify' property
At Risk: the 'hanging-punctuation' property
At Risk: Writing-system specific adjustments to line-breaking
At Risk: Trimming trailing Ogham space marks
Ignored Vars: letter-spacing
WPT Path Prefix: /css/css-text/
</pre>
<pre class=link-defaults>
spec:css2; type:dfn; text:document language
spec:css-ruby-1; type:dfn; text:ruby
</pre>
<style type="text/css">
img { vertical-align: middle; }
span[lang] {
font-size: 125%;
line-height: 1;
vertical-align: middle;
}
/* Bidi & spaces example */
.egbidiwsaA,.egbidiwsbB,.egbidiwsaB,.egbidiwsbC {
white-space: pre;
font-size: 80%;
font-family: monospace;
vertical-align: 2px;
margin: 1px;
}
.egbidiwsaA {
background: lime;
padding: 2px;
}
.egbidiwsbB { border: 2px solid blue; }
.egbidiwsaB {
background: yellow;
border: 2px dotted white;
}
.egbidiwsbC { border:2px dotted red; }
.hyphens-ex {
border: thin solid black;
display: inline-block;
padding: 4pt;
}
/* Start Letter-spacing Tutorial */
.ls-ex {
font-size: 200%;
margin-left: 1em;
margin-right: 1em;
}
.ls-fixed-width {
width: 10em;
}
.color-box { background: rgb(224, 203, 82); }
.bad { color: red; }
.good { color: green; }
/* End Letter-spacing Tutorial */
.char { border: 1px dotted gray; }
.quarter { font-size: 25%; }
tt[lang="ja"] { font-family: "MS Gothic", "Osaka", monospace; }
div.figure table {
margin: auto;
}
.feedback {
background: #FFEECC;
border-color: orange;
}
.feedback:before {
content: "Info Needed";
color: #FF8800;
}
.data .no { color: red; }
.data .ok { color: green; }
.data th em {
display: block;
font-size: smaller;
font-weight: normal;
font-style: italic;
}
.no-quote.no-quote::before,
.no-quote.no-quote::after {
content: none;
}
/* Displaying the output of text layout,
particularly when line-breaking is being invoked,
and thus having a visible width is good. */
pre.output {
margin: 1em;
border: solid thin silver;
padding: 0.25em;
display: table;
}
</style>
<h2 id="intro">
Introduction</h2>
<wpt title="
The test coverage information in this specification
covers <a href='https://github.com/web-platform-tests/wpt/tree/master/css/css-text/'>wpt/css/css-text/</a> and subdirectories,
as well as those tests in <a href='https://github.com/web-platform-tests/wpt/tree/master/css/CSS2/'>wpt/css/CSS2/</a> and subdirectories
that relate to this specification."></wpt>
This module describes the typesetting controls of CSS;
that is, the features of CSS that control the translation of
source text to formatted, line-wrapped text.
Various CSS properties provide control over
[[#transforming|case transformation]],
[[#white-space-processing|white space collapsing]],
[[#white-space-property|text wrapping]],
[[#line-breaking|line breaking rules]]
and [[#hyphenation|hyphenation]],
[[#justification|alignment and justification]],
[[#spacing|spacing]],
and [[#edge-effects|indentation]].
<div class="note">
Note: Font selection is covered in the <a href="https://www.w3.org/TR/css-fonts-3/"><cite>CSS Fonts Module</cite></a>.
[[CSS-FONTS-3]]
<span id="decoration"></span>
<span id="text-decoration"></span>
<span id="line-decoration"></span>
<span id="text-decoration-line"></span>
<span id="text-decoration-color"></span>
<span id="text-decoration-style"></span>
<span id="text-decoration-skip"></span>
<span id="text-underline-position"></span>
<span id="emphasis-marks"></span>
<span id="text-emphasis-style"></span>
<span id="text-emphasis-color"></span>
<span id="text-emphasis"></span>
<span id="text-emphasis-position"></span>
<span id="text-shadow"></span>
Features for decorating text,
such as [[css-text-decor-3#line-decoration|underlines]],
[[css-text-decor-3#emphasis-marks|emphasis marks]],
and [[css-text-decor-3#text-shadow-property|shadows]],
(previously part of this module)
are covered in the
<a href="https://www.w3.org/TR/css-text-decor-3/"><cite>CSS Text Decoration Module</cite></a>.
[[CSS-TEXT-DECOR-3]]
[[css-writing-modes-4#text-direction|Bidirectional]] and
[[css-writing-modes-4#vertical-intro|vertical]] text
are addressed in the
<a href="https://www.w3.org/TR/css-writing-modes-4/"><cite>CSS Writing Modes Module</cite></a>.
[[CSS-WRITING-MODES-4]].
</div>
Further information about the typesetting requirements
of various languages and writing systems around the world
can be found in the <a href="https://www.w3.org/International/core/">Internationalization Working Group</a>’s
<a href="https://www.w3.org/TR/typography/"><cite>Language Enablement Index</cite></a>.
[[TYPOGRAPHY]]
<wpt title="
The following tests are crash tests
that relate to general usage
of the features described in this specification
but are not tied to any particular normative statement.">
removing-collapsible-crash.html
removing-collapsible-spaces-before-float-crash.html
crashtests/line-break-float-crash.html
crashtests/trailing-space-with-cr-crash.html
ellisize-rtl-text-crash.html
altering-dom-crash.html
whitespace-followed-by-cham-symbol-crash.html
white-space/append-whitespace-only-node-crash-001.html
crashtests/rendering-rtl-bidi-override-crash.html
crashtests/rendering-table-caption-with-list-item-and-svg-crash.html
crashtests/rendering-table-caption-with-negative-margins-crash.html
crashtests/white-space-pre-wrap-chash.html
crashtests/word-spacing-large-value.html
crashtests/eol-spaces-bidi-min-content-crash.html
crashtests/overflow-wrap-anywhere-crash.html
crashtests/text-indent-each-line-crash.html
overflow-wrap/crashtests/overflow-wrap-leading-floats-crash.html
text-autospace/crashtests/text-autospace-shape-cache-crash.html
text-indent/text-indent-ruby-crash.html
</wpt>
<h3 id="placement">
Module Interactions</h3>
<wpt title="Tests not needed for this section."></wpt>
This module, together with the <cite><a href="https://www.w3.org/TR/css-text-decor-3/">CSS Text Decoration Module</a></cite>,
replaces and extends the text-level features defined in
<a href="https://www.w3.org/TR/CSS2/text.html"><cite>Cascading Style Sheets Level 2</cite> chapter 16</a>.
[[CSS-TEXT-DECOR-3]]
[[!CSS2]]
In addition to the terms defined below,
other terminology and concepts used in this specification are defined
in <a href="https://www.w3.org/TR/CSS2/"><cite>Cascading Style Sheets Level 2</cite></a>
and the <a href="https://www.w3.org/TR/css-writing-modes-4/"><cite>CSS Writing Modes Module</cite></a>.
[[!CSS2]] and [[!CSS-WRITING-MODES-4]].
<h3 id="values">
Value Definitions</h3>
<wpt title="
Tests not really needed for this section;
could possibly test that css-wide keywords apply to every property."></wpt>
This specification follows the [[CSS2/about#property-defs|CSS property definition conventions]] from [[!CSS2]]
using the [[css-values-3#value-defs|value definition syntax]] from [[!CSS-VALUES-3]].
Value types not defined in this specification are defined in CSS Values & Units [[!CSS-VALUES-3]].
Combination with other CSS modules may expand the definitions of these value types.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification
also accept the [=CSS-wide keywords=] as their property value.
For readability they have not been repeated explicitly.
<h3 id="languages">
Languages and Typesetting</h3>
<wpt title="
Tests not needed for this section:
these are definitions,
they get tested through their application,
not by themselves."></wpt>
<p class="advisement">
<strong>Authors should accurately language-tag their content
for the best typographic behavior.</strong>
Many typographic effects vary by linguistic context.
Language and writing system conventions can affect
line breaking, hyphenation, justification, glyph selection,
and many other typographic effects.
<strong>In CSS, language-specific typographic tailorings
are only applied when the [=content language=] is known (declared).</strong>
Therefore,
higher quality typography requires authors to communicate to the UA
the correct linguistic context of the text in the document.
The <dfn export>content language</dfn> of an element is the (human) language
the element is declared to be in, according to the rules of the
[=document language=].
Note that it is possible for the [=content language=] of an element
to be unknown--
e.g. untagged content,
or content in a [=document language=] that does not have a language-tagging facility,
is considered to have an unknown [=content language=].
Note: Authors can declare the [=content language=]
using the global <code>lang</code> attribute in HTML
or the universal <code>xml:lang</code> attribute in XML.
See the <a spec=html lt=language>rules for determining the content language of an HTML element</a>
in <cite>HTML</cite>,
and the [[XML#sec-lang-tag|rules for determining the content language of an XML element]] in <cite>XML 1.0</cite>.
[[HTML]]
[[XML10]]
The [=content language=] an element is declared to be in
also identifies the specific written form of that language used in that element,
known as the <dfn export local-lt="writing system">content writing system</dfn>.
Depending on the [=document language=]’s facilities for identifying the [=content language=],
this information can be explicit or implied.
See the normative [[#script-tagging]].
Note: Some languages have more than one writing system tradition;
in other cases a language can be transliterated into a foreign writing system.
Authors should [[#script-tagging|subtag]] such cases
so that the UA can adapt appropriately.
<div class=example>
For example, Korean (<code>ko</code>) can be written in
Hangul (<code>-Hang</code>),
Hanja (<code>-Hani</code>),
or a combination (<code>-Kore</code>).
Historical documents written solely in Hanja
do not use word spaces and
are formatted more like modern Chinese than modern Korean.
In other words, for typographic purposes <code>ko-Hani</code>
behaves more like <code>zh-Hant</code>
than <code>ko</code> (<code>ko-Kore</code>).
As another example Japanese (<code>ja</code>) is typically written
in a combination (<code>-Japn</code>) of Hiragana (<code>-Hira</code>),
Katakana (<code>-Kana</code>), and Kanji (<code>-Hani</code>).
However, it can also be “romanized” into Latin (<code>-Latn</code>)
for special purposes like language-learning textbooks,
in which case it should be formatted more like English than Japanese.
As a third example contemporary Mongolian is written in two scripts:
Cyrillic (<code>-Cyrl</code>, officially used in Mongolia)
and Mongolian (<code>-Mong</code>, more common in Inner Mongolia, part of China).
These have very different formatting requirements,
with Cyrillic behaving similar to Latin and Greek,
and Mongolian deriving from both Arabic and Chinese writing conventions.
</div>
<h3 id="characters">
Characters and Letters</h3>
<wpt title="
For the most part, tests not really needed for this section:
these are definitions,
they get tested through their applications,
by themselves.
The few testable assertions that are made have coverage.
Possible additions:
* turning the content of example 1 into tests (first, check that it’s not already done)."></wpt>
The basic unit of typesetting is the <dfn export>character</dfn>.
However, because writing systems are not always as simple as the basic English alphabet,
what a [=character=] actually is depends on the context in which the term is used.
For example, in Hangul (the Korean writing system),
each square representation of a syllable
(e.g. <span lang=ko-hang title="Hangul syllable HAN">한</span>=<span lang=ko-Latn>Han</span>)
can be considered a <a>character</a>.
However, the square symbol is really composed of multiple letters each representing a phoneme
(e.g. <span lang=ko-hang title="Hangul letter HIEUH">ㅎ</span>=<span lang=ko-Latn>h</span>,
<span lang=ko-hang title="Hangul letter HIEUH">ㅏ</span>=<span lang=ko-Latn>a</span>,
<span lang=ko-hang title="Hangul letter HIEUH">ㄴ</span>=<span lang=ko-Latn>n</span>)
and these also could each be considered a <a>character</a>.
A basic unit of computer text encoding, for any given encoding,
is also called a [=character=],
and depending on the encoding,
a single encoding [=character=] might correspond
to the entire pre-composed syllabic [=character=] (e.g. <span lang=ko-hang title="Hangul syllable HAN">한</span>),
to the individual phonemic [=character=] (e.g. <span lang=ko-hang title="Hangul letter HIEUH">ㅎ</span>),
or to smaller units such as
a base letterform (e.g. <span lang=ko-hang title="Hangul letter IEUNG">ㅇ</span>)
and any combining marks that vary it (e.g. extra strokes that represent aspiration).
In turn, a single encoding [=character=] can be represented in the data stream as one or more bytes;
and in programming environments one byte is sometimes also called a [=character=].
Therefore the term [=character=] is fairly ambiguous where technical precision is required.
For text layout, we will refer to the <dfn export lt="typographic character unit|typographic character">typographic character unit</dfn>
as the basic unit of text.
Even within the realm of text layout,
the relevant [=character=] unit depends on the operation.
For example, line-breaking and letter-spacing will segment
a sequence of Thai characters that include U+0E33 ำ THAI CHARACTER SARA AM differently;
or the behavior of a conjunct consonant in a script such as Devanagari
may depend on the font in use.
So the [=typographic character=] represents a unit of the writing system--
such as a Latin alphabetic letter (including its diacritics),
Hangul syllable,
Chinese ideographic character,
Myanmar syllable cluster--
that is indivisible with respect to a particular typographic operation
(line-breaking, first-letter effects, tracking, justification, vertical arrangement, etc.).
<wpt>
word-break/word-break-break-all-007.html
word-break/word-break-break-all-008.html
</wpt>
<a href="http://www.unicode.org/reports/tr29/"><cite>Unicode Standard Annex #29: Text Segmentation</cite></a>
defines a unit called the <dfn>grapheme cluster</dfn>
which approximates the [=typographic character=].
[[!UAX29]]
A UA must use the <em>extended grapheme cluster</em>
(not <em>legacy grapheme cluster</em>), as defined in <cite>UAX29</cite>,
as the basis for its [=typographic character unit=].
However, the UA should tailor the definitions
as required by typographic tradition
since the default rules are not always appropriate or ideal--
and is expected to tailor them differently
depending on the operation as needed.
<wpt>
line-breaking/line-breaking-013.html
line-breaking/line-breaking-014.html
</wpt>
Note: The rules for such tailorings are out of scope for CSS.
<div class="example">
The following are some examples of [=typographic character unit=] tailorings
required by standard typesetting practice:
<ul>
<li>
In some scripts such as Myanmar or Devanagari,
the [=typographic character unit=] for both justification and line-breaking
is an entire syllable,
which can include more than one Unicode [=grapheme cluster=].
[[!UAX29]]
<li>
In other scripts such as Thai or Lao,
even though for line-breaking the [=typographic character=]
matches Unicode’s default [=grapheme clusters=],
for letter-spacing the relevant unit
is <em>less</em> than a Unicode [=grapheme cluster=],
and may require decomposition or other substitutions
before spacing can be inserted.
[[!UAX29]]
For instance,
to properly letter-space the Thai word คำ (U+0E04 + U+0E33),
the U+0E33 needs to be decomposed into U+0E4D + U+0E32,
and then the extra letter-space inserted before the U+0E32: คํ า.
A slightly more complex example is น้ำ (U+0E19 + U+0E49 + U+0E33).
In this case, normal Thai shaping will first decompose the U+0E33 into U+0E4D + U+0E32
and then swap the U+0E4D with the U+0E49, giving U+0E19 + U+0E4D + U+0E49 + U+0E32.
As before the extra letter-space is then inserted before the U+0E32: นํ้ า.
<li>
Vertical typesetting can also require tailoring.
For example, when typesetting ''text-orientation/upright'' text,
Tibetan tsek and shad marks are kept with the preceding grapheme cluster,
rather than treated as an independent [=typographic character unit=].
[[!CSS-WRITING-MODES-4]]
</ul>
</div>
A <dfn export>typographic letter unit</dfn>
(or <dfn noexport>letter</dfn> for the purpose of this specification)
is a [=typographic character unit=] belonging to one of the Letter or Number
[=general categories=].
See [[#character-properties]]
for how to determine the Unicode properties of a [=typographic character unit=].
The rendering characteristics of a [=typographic character unit=] divided
by an element boundary is undefined.
Ideally each component should be rendered
according to the formatting requirements of its respective element’s properties
while maintaining correct shaping and positioning
of the [=typographic character unit=] as a whole.
However, depending on the nature of the formatting differences between its parts
and the capabilities of the font technology in use,
this is not always possible.
Therefore such a [=typographic character unit=]
may be rendered as belonging to either side of the boundary,
or as some approximation of belonging to both.
Authors are forewarned that dividing [=grapheme clusters=]
or ligatures
by element boundaries may give inconsistent or undesired results.
<h3 id="text-encoding">
Text Processing</h3>
<wpt title="
This section has adequate coverage.
Exhaustive coverage unrealistic,
since this section is effectively a dependency on all of Unicode.
Some tests nonetheless provided for key functionality
(such as the effect of certain control characters on Arabic shaping)."></wpt>
CSS is built on <a href="https://www.unicode.org/versions/latest/">Unicode</a>.
[[UNICODE]]
UAs that support Unicode must adhere to all normative requirements
of the Unicode Core Standard,
except where explicitly overridden by CSS.
UAs implemented on the basis of a non-Unicode text encoding model are still
expected to fulfill the same text handling requirements
by assuming an appropriate mapping and analogous behavior.
<wpt>
text-encoding/shaping-join-001.html
text-encoding/shaping-join-002.html
text-encoding/shaping-join-003.html
text-encoding/shaping-no-join-001.html
text-encoding/shaping-no-join-002.html
text-encoding/shaping-no-join-003.html
text-encoding/shaping-tatweel-001.html
text-encoding/shaping-tatweel-002.html
text-encoding/shaping-tatweel-003.html
shaping/shaping-arabic-diacritics-001.html
shaping/shaping-arabic-diacritics-002.html
white-space/full-width-leading-spaces-005.html
white-space/object-replacement-1.html
white-space/object-replacement-2.html
white-space/white-space-vs-joiners-001.html
white-space/white-space-vs-joiners-002.html
</wpt>
For the purpose of determining adjacency for text processing
(such as white space processing, text transformation, line-breaking, etc.),
and thus in general within this specification,
intervening [=inline box=] boundaries and [=out-of-flow=] elements
must be ignored.
With respect to text shaping, however, see [[#boundary-shaping]].
<wpt>
line-breaking/line-breaking-002.html
line-breaking/line-breaking-003.html
line-breaking/line-breaking-004.html
line-breaking/line-breaking-005.html
line-breaking/line-breaking-006.html
line-breaking/line-breaking-007.html
line-breaking/line-breaking-008.html
<!-- to be moved/removed together with the segment break transformation text
white-space/seg-break-transformation-018.html
white-space/seg-break-transformation-019.html
-->
word-break/word-break-min-content-002.html
word-break/word-break-min-content-003.html
word-break/word-break-min-content-004.html
word-break/word-break-min-content-005.html
overflow-wrap/overflow-wrap-anywhere-010.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-processing-048.xht
white-space-processing-049.xht
</wpt>
<h2 id="transforming">
Transforming Text</h2>
<wpt title="
This section and its subsections have good test coverage overall,
and very good i18n coverage in particular.
Missing tests:
* no test of Animation type.
* Applies to text
Possible additions:
* An automated test for plain text copy&paste not applying transforms. Not clear such an <em>automated</em> test is possible, but it would be nice to have one if it were."></wpt>
<h3 id="text-transform-property" oldids="text-transform,caps-prop">
Case Transforms: the 'text-transform' property</h3>
<pre class="propdef">
Name: text-transform
Value: none | [capitalize | uppercase | lowercase ] || full-width || full-size-kana
Initial: none
Applies to: text
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
</pre>
<wpt>
inheritance.html
parsing/text-transform-valid.html
parsing/text-transform-invalid.html
parsing/text-transform-computed.html
text-transform/text-transform-multiple-001.html
</wpt>
<wpt pathprefix="/css/CSS2/css1">
c545-txttrans-000.xht
</wpt>
<wpt pathprefix="/css/CSS2/text/">
text-transform-005.xht
text-transform-applies-to-001.xht
text-transform-applies-to-002.xht
text-transform-applies-to-003.xht
text-transform-applies-to-005.xht
text-transform-applies-to-006.xht
text-transform-applies-to-007.xht
text-transform-applies-to-008.xht
text-transform-applies-to-009.xht
text-transform-applies-to-010.xht
text-transform-applies-to-011.xht
text-transform-applies-to-012.xht
text-transform-applies-to-013.xht
text-transform-applies-to-014.xht
text-transform-applies-to-015.xht
</wpt>
This property transforms text for styling purposes.
It has no effect on the underlying content,
and must not affect the content of a plain text copy & paste operation.
<wpt>
text-transform/text-transform-upperlower-105.html
</wpt>
Advisement: Authors must not rely on 'text-transform' for semantic purposes;
rather the correct casing and semantics should be encoded
in the source document text and markup.
<wpt>
text-transform/text-transform-copy-paste-001-manual.html
</wpt>
Values have the following meanings:
<dl dfn-for=text-transform dfn-type=value>
<dt><dfn>none</dfn>
<dd>
No effects.
<wpt>
text-transform/text-transform-none-001.xht
</wpt>
<wpt pathprefix="/css/CSS2/text/">
text-transform-004.xht
</wpt>
<dt><dfn>capitalize</dfn>
<dd>
Puts the first [=typographic letter unit=] of each word, if lowercase, in titlecase;
other characters are unaffected.
<wpt>
text-transform/text-transform-capitalize-001.html
text-transform/text-transform-capitalize-003.html
text-transform/text-transform-capitalize-005.html
text-transform/text-transform-capitalize-007.html
text-transform/text-transform-capitalize-009.html
text-transform/text-transform-capitalize-010.html
text-transform/text-transform-capitalize-011.html
text-transform/text-transform-capitalize-014.html
text-transform/text-transform-capitalize-016.html
text-transform/text-transform-capitalize-018.html
text-transform/text-transform-capitalize-020.html
text-transform/text-transform-capitalize-022.html
text-transform/text-transform-capitalize-024.html
text-transform/text-transform-capitalize-026.html
text-transform/text-transform-capitalize-028.html
text-transform/text-transform-capitalize-030.html
text-transform/text-transform-capitalize-031.html
text-transform/text-transform-capitalize-032.xht
text-transform/text-transform-capitalize-034.html
text-transform/text-transform-capitalize-035.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
text-transform-001.xht
text-transform-cap-001.xht
text-transform-cap-002.xht
text-transform-cap-003.xht
</wpt>
<dt><dfn>uppercase</dfn>
<dd>
Puts all [=letters=] in uppercase.
<wpt>
text-transform/text-transform-uppercase-101.xht
text-transform/text-transform-upperlower-001.html
text-transform/text-transform-upperlower-003.html
text-transform/text-transform-upperlower-005.html
text-transform/text-transform-upperlower-007.html
text-transform/text-transform-upperlower-009.html
text-transform/text-transform-upperlower-011.html
text-transform/text-transform-upperlower-015.html
text-transform/text-transform-upperlower-017.html
text-transform/text-transform-upperlower-019.html
text-transform/text-transform-upperlower-021.html
text-transform/text-transform-upperlower-023.html
text-transform/text-transform-upperlower-025.html
text-transform/text-transform-upperlower-027.html
text-transform/text-transform-upperlower-029.html
text-transform/text-transform-upperlower-031.html
text-transform/text-transform-upperlower-044.html
text-transform/text-transform-upperlower-101.html
text-transform/text-transform-upperlower-103.html
text-transform/text-transform-upperlower-106.html
text-transform/text-transform-uppercase-dynamic.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
text-transform-003.xht
text-transform-bicameral-001.xht
text-transform-bicameral-003.xht
text-transform-bicameral-005.xht
text-transform-bicameral-007.xht
text-transform-bicameral-009.xht
text-transform-bicameral-011.xht
text-transform-bicameral-013.xht
text-transform-bicameral-015.xht
text-transform-bicameral-017.xht
text-transform-bicameral-019.xht
text-transform-bicameral-021.xht
text-transform-unicase-001.xht
text-transform-uppercase-001.xht
text-transform-uppercase-002.xht
</wpt>
<dt><dfn>lowercase</dfn>
<dd>
Puts all [=letters=] in lowercase.
<wpt>
text-transform/text-transform-lowercase-101.xht
text-transform/text-transform-lowercase-102.xht
text-transform/text-transform-upperlower-002.html
text-transform/text-transform-upperlower-004.html
text-transform/text-transform-upperlower-006.html
text-transform/text-transform-upperlower-008.html
text-transform/text-transform-upperlower-010.html
text-transform/text-transform-upperlower-012.html
text-transform/text-transform-upperlower-014.html
text-transform/text-transform-upperlower-016.html
text-transform/text-transform-upperlower-018.html
text-transform/text-transform-upperlower-020.html
text-transform/text-transform-upperlower-022.html
text-transform/text-transform-upperlower-024.html
text-transform/text-transform-upperlower-026.html
text-transform/text-transform-upperlower-028.html
text-transform/text-transform-upperlower-030.html
text-transform/text-transform-upperlower-102.html
text-transform/text-transform-upperlower-104.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
text-transform-002.xht
text-transform-bicameral-002.xht
text-transform-bicameral-004.xht
text-transform-bicameral-006.xht
text-transform-bicameral-008.xht
text-transform-bicameral-010.xht
text-transform-bicameral-012.xht
text-transform-bicameral-014.xht
text-transform-bicameral-016.xht
text-transform-bicameral-018.xht
text-transform-bicameral-020.xht
text-transform-bicameral-022.xht
text-transform-lowercase-001.xht
</wpt>
<dt><dfn>full-width</dfn>
<dd>
Puts all [=typographic character units=] in [=full-width=] form.
If a character does not have a corresponding [=full-width=] form,
it is left as is.
This value is typically used to typeset Latin letters and digits
as if they were ideographic characters.
<wpt>
text-transform/text-transform-fullwidth-001.xht
text-transform/text-transform-fullwidth-002.xht
text-transform/text-transform-fullwidth-004.xht
text-transform/text-transform-fullwidth-005.xht
</wpt>
<dt><dfn>full-size-kana</dfn>
<dd>
Converts all [=small Kana=] characters to the equivalent [=full-size Kana=].
This value is typically used for ruby annotation text,
where authors may want all small Kana to be drawn as large Kana
to compensate for legibility issues at the small font sizes typically used in ruby.
<wpt>
text-transform/text-transform-full-size-kana-001.html
text-transform/text-transform-full-size-kana-002.html
text-transform/text-transform-full-size-kana-003.html
text-transform/text-transform-full-size-kana-004.html
text-transform/text-transform-full-size-kana-005.html
text-transform/text-transform-full-size-kana-006.html
text-transform/text-transform-full-size-kana-007.html
text-transform/text-transform-full-size-kana-008.html
</wpt>
</dl>
<div class="example">
The following example converts the ASCII characters
used in abbreviations in Japanese text to their full-width variants
so that they lay out and line break like ideographs:
<pre highlight=css>abbr:lang(ja) { text-transform: full-width; }</pre>
</div>
Note: The purpose of 'text-transform' is
to allow for presentational casing transformations
without affecting the semantics of the document.
Note in particular that 'text-transform' casing operations are lossy,
and can distort the meaning of a text.
While accessibility interfaces may wish to convey
the apparent casing of the rendered text to the user,
the transformed text cannot be relied on to accurately represent
the underlying meaning of the document.
<div class="example">
In this example,
the first line of text is capitalized as a visual effect.
<pre highlight=css>
section > p:first-of-type::first-line {
text-transform: uppercase;
}
</pre>
This effect cannot be written into the source document
because the position of the line break depends on layout.
But also, the capitalization is not reflecting a semantic distinction
and is not intended to affect the paragraph’s reading;
therefore it belongs in the presentation layer.
</div>
<div class="example">
In this example,
the [=ruby=] annotations,
which are half the size of the main paragraph text,
are transformed to use regular-size kana
in place of [=small kana=].
<pre highlight=css>
rt { font-size: 50%; text-transform: full-size-kana; }
:is(h1, h2, h3, h4) rt { text-transform: none; /* unset for large text*/ }
</pre>
Note that while this makes such letters easier to see at small type sizes,
the transformation distorts the text:
the reader needs to mentally substitute [=small kana=]
in the appropriate places--
not unlike reading a Latin inscription
where all “U”s look like “V”s.
For example, if ''text-transform: full-size-kana'' were applied to the following source,
the annotation would read “じゆう” (jiyū), which means “liberty”,
instead of “じゅう” (jū), which means “ten”,
the correct reading and meaning for the annotated “十”.
<xmp highlight=html>
<ruby>十<rt>じゅう</ruby>
</xmp>
</div>
<h4 id="text-transform-mapping">
Mapping Rules</h4>
For ''capitalize'', what constitutes a “word“ is UA-dependent;
[[!UAX29]] is suggested (but not required)
for determining such word boundaries.
Out-of-flow elements and inline element boundaries
must not introduce a 'text-transform' word boundary
and must be ignored when determining such word boundaries.
<wpt>
text-transform/text-transform-capitalize-033.html
text-transform/text-transform-capitalize-034.html
text-transform/text-transform-capitalize-035.html
</wpt>
Note: Authors cannot depend on ''capitalize'' to follow
language-specific titlecasing conventions
(such as skipping articles in English).
The UA must use the full case mappings for Unicode characters,
including any conditional casing rules,
as defined in the <cite>Default Case Algorithms</cite> section of <cite>The Unicode Standard</cite>.
[[!UNICODE]]
If (and only if) the [=content language=] of the element is,
according to the rules of the [=document language=],
known,
then any appropriate language-specific rules must be applied as well.
These minimally include,
but are not limited to,
the language-specific rules in Unicode’s
<a href="http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt">SpecialCasing.txt</a>.
<wpt>
writing-system/writing-system-text-transform-001.html
text-transform/text-transform-tailoring-001.html
text-transform/text-transform-tailoring-002.html
text-transform/text-transform-tailoring-002a.html
text-transform/text-transform-tailoring-003.html
text-transform/text-transform-tailoring-004.html
text-transform/text-transform-tailoring-005.html
text-transform/text-transform-upperlower-032.html
text-transform/text-transform-upperlower-033.html
text-transform/text-transform-upperlower-034.html
text-transform/text-transform-upperlower-035.html
text-transform/text-transform-upperlower-038.html
text-transform/text-transform-upperlower-039.html
text-transform/text-transform-upperlower-040.html
text-transform/text-transform-upperlower-041.html
text-transform/text-transform-upperlower-042.html
text-transform/text-transform-upperlower-043.html
</wpt>
<div class="example">
For example, in Turkish there are two “i”s,
one with a dot--
“İ” and “i”--
and one without--
“I” and “ı”.
Thus the usual case mappings between “I” and “i”
are replaced with a different set of mappings
to their respective dotless/dotted counterparts,
which do not exist in English.
This mapping must only take effect
if the [=content language=] is Turkish
written in its modern Latin-based [=writing system=]
(or another Turkic language that uses Turkish casing rules);
in other languages,
the usual mapping of “I” and “i” is required.
This rule is thus conditionally defined in Unicode’s SpecialCasing.txt file.
</div>
<wpt pathprefix="/css/CSS2/text/">
text-transform-bicameral-005.xht
text-transform-bicameral-006.xht
</wpt>
The definition of <dfn>full-width</dfn> and <dfn noexport>half-width</dfn> forms
can be found in <a href="https://www.unicode.org/reports/tr11/"><cite></cite>Unicode Standard Annex #11: East Asian Width</a>.
[[!UAX11]]
The mapping to [=full-width=] form is defined
by taking code points with the <code><wide></code>
or the <code><narrow></code> tag
in their <code>Decomposition_Mapping</code>
in <a href="https://www.unicode.org/reports/tr44/"><cite></cite>Unicode Standard Annex #44: Unicode Character Database</a>.
[[!UAX44]]
For the <code><narrow></code> tag,
the mapping is from the code point to the decomposition
(minus <code><narrow></code> tag),
and for the <code><wide></code> tag,
the mapping is from the decomposition
(minus the <code><wide></code> tag)
back to the original code point.
<wpt>
text-transform/text-transform-fullwidth-001.xht
text-transform/text-transform-fullwidth-002.xht
text-transform/text-transform-fullwidth-004.xht
text-transform/text-transform-fullwidth-005.xht
text-transform/text-transform-fullwidth-006.html
text-transform/text-transform-fullwidth-007.html
</wpt>
The mappings for [=small Kana=] to [=full-size Kana=] are defined in [[#small-kana]].
<h4 id="text-transform-order">
Order of Operations</h4>
When multiple values are specified
and therefore multiple transformations need to be applied,
they are applied in the following order:
<ol>
<li>''capitalize'', ''uppercase'', and ''lowercase''
<li>''full-width''
<li>''full-size-kana''
</ol>
<wpt>
text-transform/text-transform-multiple-001.html
</wpt>
Text transformation happens after [[#white-space-phase-1]]
but before [[#white-space-phase-2]].
This means that ''full-width'' only transforms
spaces (U+0020) to U+3000 IDEOGRAPHIC SPACE within [=preserved=] [=white space=].
<wpt>
text-transform/text-transform-fullwidth-006.html
text-transform/text-transform-fullwidth-007.html
text-transform/text-transform-fullwidth-008.html
text-transform/text-transform-fullwidth-009.html
</wpt>
Note: As defined in [[#order]],
transforming text affects line-breaking and other formatting operations.
<h2 id="white-space-property" oldids="white-space-collapsing,text-wrap">
White Space and Wrapping: the 'white-space' property</h2>
<wpt title="
This section has good overall test coverage,
particularly through tests for [[#white-space-processing]] and subsections.
Missing tests:
* No test of Animation type
* Intrinsic (min and max) sizing tests for normal and nowrap."></wpt>
<pre class="propdef">
Name: white-space
Value: normal | pre | nowrap | pre-wrap | break-spaces | pre-line
Initial: normal
Applies to: text
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete