8000 csswg-drafts/css2/text.html at b66760ec149cec9c26d60ccb4ee6347d17bb4e9c · xfq/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
745 lines (665 loc) · 33.7 KB

File metadata and controls

745 lines (665 loc) · 33.7 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>Text</title>
<link rel="stylesheet" href="style/default.css" type="text/css">
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-ED.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">previous</a> &nbsp;
<a href="tables.html">next</a> &nbsp;
<a href="cover.html#minitoc">contents</a> &nbsp;
<a href="propidx.html">properties</a> &nbsp;
<a href="indexlist.html">index</a> &nbsp;
</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>&nbsp;&nbsp;<td><a href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length">&lt;length&gt;</span></a> | <a href="syndata.html#value-def-percentage" class="noxref"><span class="value-inst-percentage">&lt;percentage&gt;</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>&nbsp;&nbsp;<td>0
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>block containers
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>yes
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>refer to width of containing block
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<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="&lt;length&gt;"><a name="x1" href="syndata.html#value-def-length" class="noxref"><span
class="value-inst-length">&lt;length&gt;</span></a></span></dt>
<dd>The indentation is a fixed length.</dd>
<dt><span class="index-inst" title="&lt;percentage&gt;"><a name="x2" href="syndata.html#value-def-percentage" class="noxref"><span
class="value-inst-percentage">&lt;percentage&gt;
</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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<td>block containers
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>yes
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<td>none
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>all elements
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>no (see prose)
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<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&nbsp;9.2.1.1</a>).
But, in CSS&nbsp;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&nbsp;2.1 does not specify if the underline is visible or
invisible in E's children:</em>
<pre class=html-example>
&lt;span style="visibility: hidden; text-decoration: underline"&gt;
&lt;span style="visibility: visible"&gt;
underlined or not?
&lt;/span&gt;
&lt;/span&gt;
</pre>
<p><em>This is expected to be specified in level&nbsp;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&nbsp;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">
&lt;blockquote&gt;
&lt;p&gt;
&lt;span&gt;
Help, help!
&lt;em&gt; I am under a hat! &lt;/em&gt;
&lt;cite&gt; &mdash;GwieF &lt;/cite&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
</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>&lt;em&gt;text&lt;/em&gt;</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>&nbsp;&nbsp;<td>normal | <a href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length">&lt;length&gt;</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>&nbsp;&nbsp;<td>normal
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>all elements
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>yes
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<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="&lt;length&gt;"><a name="x7" href="syndata.html#value-def-length" class="noxref"><span
class="value-inst-length">&lt;length&gt;</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>&nbsp;&nbsp;<td>normal | <a href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length">&lt;length&gt;</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>&nbsp;&nbsp;<td>normal
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>all elements
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>yes
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<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="&lt;length&gt;"><a name="x10" href="syndata.html#value-def-length" class="noxref"><span
class="value-inst-length">&lt;length&gt;</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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<td>none
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>all elements
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>yes
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<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&nbsp;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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<td>normal
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>all elements
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>yes
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<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
r 4B74 eturn (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) &mdash; even
a space before the inline, if that space also has
'white-space' set to 'normal', 'nowrap' or 'pre-line' &mdash; 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>
&lt;ltr&gt;A<span class="egbidiwsaA">&nbsp;</span>&lt;rtl&gt;<span class="egbidiwsbB">&nbsp;</span>B<span class="egbidiwsaB">&nbsp;</span>&lt;/rtl&gt;<span class="egbidiwsbC">&nbsp;</span>C&lt;/ltr&gt;
</code></pre>
<p>
...where the <code>&lt;ltr&gt;</code> element represents a left-to-right embedding and
the <code>&lt;rtl&gt;</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">&nbsp;</span>) would collapse with the space after the A (<span class="egbidiwsaA">&nbsp;</span>).</li>
<li>The space before the C (<span class="egbidiwsbC">&nbsp;</span>) would collapse with the space after the B (<span class="egbidiwsaB">&nbsp;</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">&nbsp;</span><span class="egbidiwsaB">&nbsp;</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&lt;span&gt;&amp;#x308;&lt;/span&gt;</code>"; it does not just
match the base character.</p>
<hr class="navbar">
<div class="navbar">
<p><a href="fonts.html">previous</a> &nbsp;
<a href="tables.html">next</a> &nbsp;
<a href="cover.html#minitoc">contents</a> &nbsp;
<a href="propidx.html">properties</a> &nbsp;
<a href="indexlist.html">index</a> &nbsp;
</div>
</body>
</html>