-
Notifications
You must be signed in to change notification settings - Fork 0
/
text.html
746 lines (666 loc) · 33.7 KB
/
text.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta charset="UTF-8">
<title>Text</title>
<link rel="stylesheet" href="style/default.css" type="text/css">
<link rel="stylesheet" href="style/W3C-REC.css" type="text/css">
<link rel="prev" href="fonts.html">
<link rel="next" href="tables.html">
<link rel="contents" href="cover.html#minitoc">
<link rel="CSS-properties" href="propidx.html" title="properties">
<link rel="index" href="indexlist.html" title="index">
<link rel="first" href="cover.html">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
.current,.proposed,span.delcurrent { background:#feb }
ins.proposed,span.insproposed { background:#bfb }
del.proposed,span.delproposed { background:#fbb }
span.insproposed { text-decoration:underline }
span.delproposed,span.delcurrent { text-decoration:line-through }
body>del,body>ins {display:block}
</style>
<style type="text/css">
.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 }
</style>
</head>
<body>
<div class="navbar">
<p><a href="fonts.html">上一章</a>
<a href="tables.html">下一章</a>
<a href="cover.html#minitoc">目录</a>
<a href="propidx.html">属性表</a>
<a href="indexlist.html">索引</a>
</div>
<hr class="navbar">
<h1><a name="q0">16 Text</a></h1>
<div class="subtoc">
<p><strong>Contents</strong>
<ul class="toc">
<li class="tocline2"><a href="text.html#indentation-prop" class="tocxref">16.1 Indentation: the <span class="propinst-text-indent">'text-indent'</span> property</a>
<li class="tocline2"><a href="text.html#alignment-prop" class="tocxref">16.2 Alignment: the <span class="propinst-text-align">'text-align'</span> property</a>
<li class="tocline2"><a href="text.html#decoration" class="tocxref">16.3 Decoration</a>
<ul class="toc">
<li class="tocline3"><a href="text.html#lining-striking-props" class="tocxref">16.3.1 Underlining, overlining, striking, and blinking: the <span class="propinst-text-decoration">'text-decoration'</span> property</a>
</ul>
<li class="tocline2"><a href="text.html#spacing-props" class="tocxref">16.4 Letter and word spacing: the <span class="propinst-letter-spacing">'letter-spacing'</span> and <span class="propinst-word-spacing">'word-spacing'</span> properties</a>
<li class="tocline2"><a href="text.html#caps-prop" class="tocxref">16.5 Capitalization: the <span class="propinst-text-transform">'text-transform'</span> property</a>
<li class="tocline2"><a href="text.html#white-space-prop" class="tocxref">16.6 White space: the <span class="propinst-white-space">'white-space'</span> property</a>
<ul class="toc">
<li class="tocline3"><a href="text.html#white-space-model" class="tocxref">16.6.1 The 'white-space' processing model</a>
<li class="tocline3"><a href="text.html#egbidiwscollapse" class="tocxref">16.6.2 Example of bidirectionality with white space collapsing</a>
<li class="tocline3"><a href="text.html#ctrlchars" class="tocxref">16.6.3 Control and combining characters' details</a>
</ul>
</ul>
</div>
<p>The properties defined in the following sections affect the visual
presentation of characters, spaces, words, and paragraphs.
</p>
<h2>16.1 <a name="indentation-prop">Indentation</a>: the <a href="text.html#propdef-text-indent" class="noxref"><span
class="propinst-text-indent">'text-indent'</span></a> property</h2>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'text-indent'"><a name="propdef-text-indent" class="propdef-title"><strong>'text-indent'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em> <td><a href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length"><length></span></a> | <a href="syndata.html#value-def-percentage" class="noxref"><span class="value-inst-percentage"><percentage></span></a> | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em> <td>0
<tr valign=baseline><td><em>Applies to:</em> <td>block containers
<tr valign=baseline><td><em>Inherited:</em> <td>yes
<tr valign=baseline><td><em>Percentages:</em> <td>refer to width of containing block
<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed value:</em> <td>the percentage as specified or the absolute length
</table>
</dl>
</div>
<p>This property specifies the indentation of the first line of text
in a block container. More precisely, it specifies the indentation of the
first box that flows into the block's first <a
href="visuren.html#line-box">line box</a>. The box is indented with
respect to the left (or right, for right-to-left layout) edge of the
line box. User agents must render this indentation as blank space.
</p>
<p>'Text-indent' only affects a line if it is the <a
href="selector.html#first-line-pseudo">first formatted line</a> of an
element. For example, the first line of an anonymous block box is only
affected if it is the first child of its parent element.
<p>Values have the following meanings:</p>
<dl>
<dt><span class="index-inst" title="<length>"><a name="x1" href="syndata.html#value-def-length" class="noxref"><span
class="value-inst-length"><length></span></a></span></dt>
<dd>The indentation is a fixed length.</dd>
<dt><span class="index-inst" title="<percentage>"><a name="x2" href="syndata.html#value-def-percentage" class="noxref"><span
class="value-inst-percentage"><percentage>
</span></a></span></dt>
<dd>The indentation is a percentage of the containing
block width.</dd>
</dl>
<p>The value of <a href="text.html#propdef-text-indent" class="noxref"><span
class="propinst-text-indent">'text-indent'</span></a> may be negative, but
there may be implementation-specific limits.
If the value of <a href="text.html#propdef-text-indent" class="noxref"><span
class="propinst-text-indent">'text-indent'</span></a> is either negative or
exceeds the width of the block, that <em>first box</em>, described above,
can overflow the block.
The value of <a href="visufx.html#propdef-overflow" class="noxref"><span class="propinst-overflow">'overflow'</span></a> will affect
whether such text that overflows the block is visible.
</p>
<div class="example"><P style="display:none">Example(s):</P><p>
The following example causes a '3em' text indent.
</p>
<pre><code class="css">
p { text-indent: 3em }
</code></pre>
</div>
<p class="note">
Note: Since the 'text-indent' property inherits, when specified on
a block element, it will affect descendant inline-block elements.
For this reason, it is often wise to specify '<code>text-indent: 0</code>'
on elements that are specified '<code>display:inline-block</code>'.
</p>
<h2>16.2 <a name="alignment-prop">Alignment:</a> the <a href="text.html#propdef-text-align" class="noxref"><span
class="propinst-text-align">'text-align'</span></a> property</h2>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'text-align'"><a name="propdef-text-align" class="propdef-title"><strong>'text-align'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em> <td>left | right | center | justify | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em> <td>a nameless value that acts as 'left' if 'direction' is 'ltr',
'right' if 'direction' is 'rtl'
<tr valign=baseline><td><em>Applies to:</em> <td>block containers
<tr valign=baseline><td><em>Inherited:</em> <td>yes
<tr valign=baseline><td><em>Percentages:</em> <td>N/A
<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed value:</em> <td>the initial value or as specified
</table>
</dl>
</div>
<p>This property describes how inline-level content of a block
container is aligned. Values
have the following meanings:</p>
<dl>
<dt>left, right, center, justify</dt>
<dd>Left, right, center, and justify text, respectively, as described in <a href="visuren.html#inline-formatting">the section on inline formatting</a>.</dd>
</dl>
<p>A block of text is a stack of <a href="visuren.html#line-box">line
boxes</a>. In the case of 'left', 'right' and 'center', this property specifies
how the inline-level boxes within each line box align with respect to the line
box's left and right sides; alignment is not with respect to the <a
href="visuren.html#viewport">viewport</a>. In the case of 'justify',
this property specifies that the inline-level boxes are to be made flush
with both sides of the line box if possible, by expanding or contracting
the contents of inline boxes, else aligned as for the initial
value. (See also <a href="text.html#propdef-letter-spacing" class="noxref"><span
class="propinst-letter-spacing">'letter-spacing'</span></a> and <a href="text.html#propdef-word-spacing" class="noxref"><span
class="propinst-word-spacing">'word-spacing'</span></a>.)
</p>
<p>
If an element has a computed value for 'white-space' of 'pre' or
'pre-wrap', then neither the glyphs of that element's text content nor
its white space may be altered for the purpose of justification.
</p>
<p class=note>Note: CSS may add a way to justify text with
'white-space: pre-wrap' in the future.
<div class="example"><P style="display:none">Example(s):</P><p>
In this example, note that since <a href="text.html#propdef-text-align" class="noxref"><span
class="propinst-text-align">'text-align'</span></a> is inherited, all
block-level elements inside DIV elements with a class name of 'important' will
have their inline content centered.
</p>
<pre><code class="css">
div.important { text-align: center }
</code></pre>
</div>
<div class="note"><p>
<em><strong>Note.</strong>
The actual justification algorithm used depends on the user-agent and the language/script
of the text.</em>
</p>
</div>
<p><em><span class="index-inst" title="conformance"><a name="x4"
href="conform.html#conformance">Conforming user agents</a></span> may
interpret the value 'justify' as 'left' or 'right', depending on
whether the element's default writing direction is left-to-right or
right-to-left, respectively.</em>
</p>
<h2>16.3 <a name="decoration">Decoration</a></h2>
<h3>16.3.1 <a name="lining-striking-props">Underlining, overlining, striking, and
blinking</a>: the <a href="text.html#propdef-text-decoration" class="noxref"><span
class="propinst-text-decoration">'text-decoration'</span></a>
property</h3>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'text-decoration'"><a name="propdef-text-decoration" class="propdef-title"><strong>'text-decoration'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em> <td>none | [ underline || overline || line-through || blink ] | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em> <td>none
<tr valign=baseline><td><em>Applies to:</em> <td>all elements
<tr valign=baseline><td><em>Inherited:</em> <td>no (see prose)
<tr valign=baseline><td><em>Percentages:</em> <td>N/A
<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed value:</em> <td>as specified
</table>
</dl>
</div>
<p>
This property describes decorations that are added
to the text of an element using the element's color.
When specified on or propagated to an inline element, it
affects all the boxes generated by that element, and is further
propagated to any in-flow block-level boxes that split the inline (see
<a href="visuren.html#anonymous-block-level"
>section 9.2.1.1</a>).
But, in CSS 2.1, it is undefined whether the decoration
propagates into block-level tables.
For block containers that establish an
<a href="visuren.html#inline-formatting" >inline formatting
context,</a> the decorations are propagated to an anonymous inline
element that wraps all the in-flow inline-level children of the block
container. For all other elements it is propagated to any in-flow
children. Note that text decorations are not propagated to floating
and absolutely positioned descendants, nor to the contents of atomic
inline-level descendants such as inline blocks and inline tables.
<p>
Underlines, overlines, and line-throughs are applied only to text
(including white space, letter spacing, and word spacing): margins,
borders, and padding are skipped.
User agents must not render these text decorations on content that is
not text. For example, images and inline blocks must not be underlined.
<div class=note>
<p><em><strong>Note.</strong> If an element E has both 'visibility:
hidden' and 'text-decoration: underline', the underline is invisible
(although any decoration of E's parent <strong>is</strong> visible.)
However, CSS 2.1 does not specify if the underline is visible or
invisible in E's children:</em>
<pre class=html-example>
<span style="visibility: hidden; text-decoration: underline">
<span style="visibility: visible">
underlined or not?
</span>
</span>
</pre>
<p><em>This is expected to be specified in level 3 of CSS.</em>
</div>
<p>
The 'text-decoration' property on descendant elements cannot have any
effect on the decoration of the ancestor. In determining the position
of and thickness of text decoration lines, user agents may consider the
font sizes of and dominant baselines of descendants, but must use the
same baseline and thickness on each line. Relatively positioning a
descendant moves all text decorations affecting it along with the
descendant's text; it does not affect calculation of the decoration's
initial position on that line.
</p>
<p>Values have the following meanings:</p>
<dl>
<dt>none</dt>
<dd>Produces no text decoration.</dd>
<dt>underline</dt>
<dd>Each line of text is underlined.</dd>
<dt>overline</dt>
<dd>Each line of text has a line above it.</dd>
<dt>line-through</dt>
<dd>Each line of text has a line through the middle.</dd>
<dt>blink</dt>
<dd>Text blinks (alternates between visible and invisible).
<a href="conform.html#conformance">Conforming user agents</a>
may simply not blink the text. Note that not blinking the text
is one technique to satisfy
<a href="http://www.w3.org/TR/UAAG/guidelines.html#tech-on-off-blinking-text">checkpoint 3.3 of WAI-UAAG</a>.</dd>
</dl>
<p>
The color(s) required for the text decoration must be derived from
the <a href="colors.html#propdef-color" class="noxref"><span class="propinst-color">'color'</span></a> property value of the element on which 'text-decoration'
is set. The color of decorations must remain the same even if
descendant elements have different <a href="colors.html#propdef-color" class="noxref"><span class="propinst-color">'color'</span></a> values.
</p>
<p>
Some user agents have implemented text-decoration by
propagating the decoration to the descendant elements as opposed to
preserving a constant thickness and line position as described
above. This was arguably allowed by the looser wording in CSS2. SVG1,
CSS1-only, and CSS2-only user agents may implement the older model
and still claim conformance to this part of CSS 2.1. (This does not
apply to UAs developed after this specification was released.)
</p>
<div class="example"><P style="display:none">Example(s):</P><p>
In the following example for HTML, the text content of all
A elements acting as hyperlinks (whether visited or not) will be underlined:</p>
<pre><code class="css">
a:visited,a:link { text-decoration: underline }
</code></pre>
</div>
<div class="example"><P style="display:none">Example(s):</P><p>
In the following style sheet and document fragment:
</p>
<pre><code class="css">
blockquote { text-decoration: underline; color: blue; }
em { display: block; }
cite { color: fuchsia; }
</code></pre>
<pre><code class="html">
<blockquote>
<p>
<span>
Help, help!
<em> I am under a hat! </em>
<cite> —GwieF </cite>
</span>
</p>
</blockquote>
</code></pre>
<p>
...the underlining for the blockquote element is propagated to an
anonymous inline element that surrounds the span element, causing
the text "Help, help!" to be blue, with the blue underlining from
the anonymous inline underneath it, the color being taken from the
blockquote element. The <code><em>text</em></code>
in the em block is also underlined,
as it is in an in-flow block to which the underline is propagated. The final line of text is fuchsia, but the underline
underneath it is still the blue underline from the anonymous inline
element.
</p>
<p><img src="images/underline-example.png" alt="Sample rendering of the above underline example">
</p>
<p>
This diagram shows the boxes involved in the example above. The rounded
aqua line represents the anonymous inline element wrapping the inline
contents of the paragraph element, the rounded blue line represents
the span element, and the orange lines represent the blocks.
</p>
</div>
<h2>16.4 <a name="spacing-props">Letter and word spacing</a>: the <a href="text.html#propdef-letter-spacing" class="noxref"><span
class="propinst-letter-spacing">'letter-spacing'</span></a> and <a href="text.html#propdef-word-spacing" class="noxref"><span
class="propinst-word-spacing">'word-spacing'</span></a> properties</h2>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'letter-spacing'"><a name="propdef-letter-spacing" class="propdef-title"><strong>'letter-spacing'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em> <td>normal | <a href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length"><length></span></a> | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em> <td>normal
<tr valign=baseline><td><em>Applies to:</em> <td>all elements
<tr valign=baseline><td><em>Inherited:</em> <td>yes
<tr valign=baseline><td><em>Percentages:</em> <td>N/A
<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed value:</em> <td>'normal' or absolute length
</table>
</dl>
</div>
<p>This property specifies spacing behavior between
text characters. Values have the following meanings:</p>
<dl>
<dt>normal</dt>
<dd>The spacing is the normal spacing for the current font.
This value allows the user agent to alter the space
between characters in order to justify text.</dd>
<dt><span class="index-inst" title="<length>"><a name="x7" href="syndata.html#value-def-length" class="noxref"><span
class="value-inst-length"><length></span></a></span></dt>
<dd>This value indicates inter-character space <em>in
addition to</em> the default space between
characters. Values may be negative, but there may be
implementation-specific limits.
User agents may not further increase or decrease the inter-character
space in order to justify text.</dd>
</dl>
<p>Character spacing algorithms are user agent-dependent.
</p>
<div class="example"><P style="display:none">Example(s):</P><p>
In this example, the space between characters in
BLOCKQUOTE elements is increased by '0.1em'.
</p>
<pre><code class="css">
blockquote { letter-spacing: 0.1em }
</code></pre>
<p>In the following example, the user agent is not permitted
to alter inter-character space:</p>
<pre><code class="css">
blockquote { letter-spacing: 0cm } /* Same as '0' */
</code></pre>
</div>
<p> When the resultant space between two characters is not the same as
the default space, user agents should not use
<a name="x8"><span class="index-inst" title="ligatures">ligatures.</span></a>
</p>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'word-spacing'"><a name="propdef-word-spacing" class="propdef-title"><strong>'word-spacing'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em> <td>normal | <a href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length"><length></span></a> | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em> <td>normal
<tr valign=baseline><td><em>Applies to:</em> <td>all elements
<tr valign=baseline><td><em>Inherited:</em> <td>yes
<tr valign=baseline><td><em>Percentages:</em> <td>N/A
<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed value:</em> <td>for 'normal' the value '0'; otherwise the absolute length
</table>
</dl>
</div>
<p>This property specifies spacing behavior between words.
Values have the following meanings:</p>
<dl>
<dt>normal</dt>
<dd>The normal inter-word space, as defined by the current font and/or
the <abbr title="user agent">UA</abbr>.</dd>
<dt><span class="index-inst" title="<length>"><a name="x10" href="syndata.html#value-def-length" class="noxref"><span
class="value-inst-length"><length></span></a></span></dt>
<dd>This value indicates inter-word space <em>in
addition to</em> the default space between
words. Values may be negative, but there may be
implementation-specific limits. </dd>
</dl>
<p>Word spacing algorithms are user agent-dependent. Word spacing is
also influenced by justification (see the <a href="text.html#propdef-text-align" class="noxref"><span
class="propinst-text-align">'text-align'</span></a> property).
Word spacing affects each space (U+0020) and non-breaking space
(U+00A0), left in the text after the white space processing rules have
been applied. The effect of the property on other word-separator
characters is undefined. However general punctuation, characters with
zero advance width (such as the zero with space U+200B) and
fixed-width spaces (such as U+3000 and U+2000 through U+200A) are not
affected.
<div class="example"><P style="display:none">Example(s):</P><p>
In this example, the word-spacing between each word in H1 elements is
increased by '1em'.
</p>
<pre><code class="css">
h1 { word-spacing: 1em }
</code></pre>
</div>
<h2>16.5 <a name="caps-prop">Capitalization</a>: the <a href="text.html#propdef-text-transform" class="noxref"><span
class="propinst-text-transform">'text-transform'</span></a> property</h2>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'text-transform'"><a name="propdef-text-transform" class="propdef-title"><strong>'text-transform'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em> <td>capitalize | uppercase | lowercase | none | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em> <td>none
<tr valign=baseline><td><em>Applies to:</em> <td>all elements
<tr valign=baseline><td><em>Inherited:</em> <td>yes
<tr valign=baseline><td><em>Percentages:</em> <td>N/A
<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed value:</em> <td>as specified
</table>
</dl>
</div>
<p>This property controls capitalization effects of
an element's text. Values have the following meanings:</p>
<dl>
<dt>capitalize</dt>
<dd>Puts the first character of each word in uppercase; other characters are unaffected.</dd>
<dt>uppercase</dt>
<dd>Puts all characters of each word in uppercase.</dd>
<dt>lowercase</dt>
<dd>Puts all characters of each word in lowercase.</dd>
<dt>none</dt>
<dd>No capitalization effects.</dd>
</dl>
<p> The actual transformation in each case is written language
dependent. See BCP 47 (<a href="refs.html#ref-BCP47" rel="biblioentry" class="noxref"><span class="informref">[BCP47]</span></a>) for ways to find the language of
an element.
</p>
<p>Only characters belonging to "bicameral scripts" <a href="refs.html#ref-UNICODE" rel="biblioentry" class="noxref"><span class="normref">[UNICODE]</span></a> are
affected.
</p>
<div class="example"><P style="display:none">Example(s):</P><p>
In this example, all text in an H1 element is transformed to uppercase
text.
</p>
<pre><code class="css">
h1 { text-transform: uppercase }
</code></pre>
</div>
<h2>16.6 <a name="white-space-prop">White space</a>: the <a href="text.html#propdef-white-space" class="noxref"><span
class="propinst-white-space">'white-space'</span></a> property</h2>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'white-space'"><a name="propdef-white-space" class="propdef-title"><strong>'white-space'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em> <td>normal | pre | nowrap | pre-wrap | pre-line | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em> <td>normal
<tr valign=baseline><td><em>Applies to:</em> <td>all elements
<tr valign=baseline><td><em>Inherited:</em> <td>yes
<tr valign=baseline><td><em>Percentages:</em> <td>N/A
<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed value:</em> <td>as specified
</table>
</dl>
</div>
<p> This property declares how white space inside the element is
handled. Values have the following meanings:</p>
<dl>
<dt>normal</dt>
<dd>This value directs user agents to collapse sequences
of white space, and break lines as necessary to fill line boxes.</dd>
<dt>pre</dt>
<dd>This value prevents user agents from collapsing sequences
of white space. Lines are only broken at preserved newline characters.</dd>
<dt>nowrap</dt>
<dd>This value collapses white space as for 'normal', but suppresses
line breaks within text.</dd>
<dt>pre-wrap</dt>
<dd>This value prevents user agents from collapsing sequences
of white space. Lines are broken at preserved newline characters,
and as necessary to fill line boxes.</dd>
<dt>pre-line</dt>
<dd>This value directs user agents to collapse sequences of white
space. Lines are broken at preserved newline characters, and as
necessary to fill line boxes.</dd>
</dl>
<p>
Newlines in the source can be represented by a carriage return
(U+000D), a linefeed (U+000A) or both (U+000D U+000A) or by some other
mechanism that identifies the beginning and end of document segments,
such as the SGML RECORD-START and RECORD-END tokens. The CSS
'white-space' processing model assumes all newlines have been
normalized to line feeds.
UAs that recognize other newline representations must apply the white
space processing rules as if this normalization has taken place. If no
newline rules are specified for the document language, each carriage
return (U+000D) and CRLF sequence (U+000D U+000A) in the document text
is treated as single line feed character.
This default normalization rule also applies to generated
content.
<p>UAs must recognize line feeds (U+000A) as newline characters. UAs
may additionally treat other forced break characters as newline
characters per UAX14.
<div class="example"><P style="display:none">Example(s):</P><p> The following examples show what <a
href="syndata.html#whitespace">white space</a> behavior is expected
from the PRE and P elements and the "nowrap" attribute in HTML.
<pre><code class="css">
pre { white-space: pre }
p { white-space: normal }
td[nowrap] { white-space: nowrap }
</code></pre>
<p>In addition, the effect of an HTML PRE element with the <em>non-standard</em> "wrap" attribute is demonstrated by the following example:
</p>
<pre><code class="css">
pre[wrap] { white-space: pre-wrap }
</code></pre>
</div>
<h3>16.6.1 <a name="white-space-model">The 'white-space' processing model</a></h3>
<p>
For each inline element (including anonymous inline elements), the
following steps are performed, treating bidi formatting characters as if
they were not there:
</p>
<ol>
<li>
Each tab (U+0009), carriage return (U+000D), or space (U+0020)
character surrounding a linefeed (U+000A) character is removed if
'white-space' is set to 'normal', 'nowrap', or 'pre-line'.
</li>
<li>If 'white-space' is set to 'pre' or 'pre-wrap', any sequence of
spaces (U+0020) unbroken by an element boundary is treated as a
sequence of non-breaking spaces. However, for 'pre-wrap', a line breaking
opportunity exists at the end of the sequence.
</li>
<li>If 'white-space' is set to 'normal' or 'nowrap', linefeed
characters are transformed for rendering purpose into one of the
following characters: a space character, a zero width space
character (U+200B), or no character (i.e., not rendered),
according to UA-specific algorithms based on the content script.
</li>
<li>If 'white-space' is set to 'normal', 'nowrap', or 'pre-line',
<ol><li> every tab (U+0009) is converted to a space (U+0020)</li>
<li> any space (U+0020) following another space (U+0020) — even
a space before the inline, if that space also has
'white-space' set to 'normal', 'nowrap' or 'pre-line' — is removed.</li>
</ol>
</li>
</ol>
<p>
Then, the block container's inlines are laid out. Inlines are laid
out, taking bidi
reordering into account, and wrapping as specified by the
'white-space' property.
When wrapping, line breaking opportunities are determined based
on the text prior to the white space collapsing steps above.
</p>
<p>
As each line is laid out,
</p>
<ol>
<li>If a space (U+0020) at the beginning of a line has 'white-space'
set to 'normal', 'nowrap', or 'pre-line', it is removed.
</li>
<li>All tabs (U+0009) are rendered as a horizontal shift that lines
up the start edge of the next glyph with the next tab stop. Tab
stops occur at points that are multiples of 8 times the width of
a space (U+0020) rendered in the block's font from the block's
starting content edge.
</li>
<li>If a space (U+0020) at the end of a line has 'white-space' set to
'normal', 'nowrap', or 'pre-line', it is also removed.
</li>
<li>If spaces (U+0020) or tabs (U+0009) at the end of a line have
'white-space' set to 'pre-wrap', UAs may visually collapse them.
</ol>
<p>Floated and absolutely-positioned elements do not introduce a line
breaking opportunity.
<div class="note"><p>
<em><strong>Note.</strong>
CSS 2.1 does not fully define where line breaking opportunities occur.</em>
</div>
<h3>16.6.2 <a name="egbidiwscollapse">Example of bidirectionality with white space collapsing</a></h3>
<p>
Given the following markup fragment, taking special note of spaces (with varied backgrounds and borders for emphasis and identification):
</p>
<pre><code>
<ltr>A<span class="egbidiwsaA"> </span><rtl><span class="egbidiwsbB"> </span>B<span class="egbidiwsaB"> </span></rtl><span class="egbidiwsbC"> </span>C</ltr>
</code></pre>
<p>
...where the <code><ltr></code> element represents a left-to-right embedding and
the <code><rtl></code> element represents a right-to-left embedding, and
assuming that the 'white-space' property is set to 'normal', the
above processing model would result in the following:
</p>
<ul style="line-height:1.3">
<li>The space before the B (<span class="egbidiwsbB"> </span>) would collapse with the space after the A (<span class="egbidiwsaA"> </span>).</li>
<li>The space before the C (<span class="egbidiwsbC"> </span>) would collapse with the space after the B (<span class="egbidiwsaB"> </span>).</li>
</ul>
<p>
This would leave two spaces, one after the A in the left-to-right
embedding level, and one after the B in the right-to-left embedding
level. This is then rendered according to the Unicode bidirectional
algorithm, with the end result being:
</p>
<pre>
A<span class="egbidiwsaA"> </span><span class="egbidiwsaB"> </span>BC
</pre>
<p>
Note that there are two spaces between A and B, and none between B
and C. This can sometimes be avoided by using the natural bidirectionality
of characters instead of explicit embedding levels. Also, it is good
to avoid spaces immediately inside start and end tags, as these tend
to do weird things when dealing with white space collapsing.
</p>
<h3>16.6.3 <a name="ctrlchars">Control and combining characters' details</a></h3>
<p>Control characters other than U+0009 (tab), U+000A (line feed),
U+0020 (space), and U+202x (bidi formatting characters) are treated as
characters to render in the same way as any normal character.</p>
<p>Combining characters should be treated as part of the character
with which they are supposed to combine. For example, :first-letter
styles the entire glyph if you have content like
"<code>o<span>&#x308;</span></code>"; it does not just
match the base character.</p>
<hr class="navbar">
<div class="navbar">
<p><a href="fonts.html">上一章</a>
<a href="tables.html">下一章</a>
<a href="cover.html#minitoc">目录</a>
<a href="propidx.html">属性表</a>
<a href="indexlist.html">索引</a>
</div>
</body>
</html>