8000 csswg-drafts/css-text/Overview.src.html at 46d0186b580e97c634663e4a07477f9b3c1abe7a · xfq/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
2697 lines (2397 loc) · 114 KB

File metadata and controls

2697 lines (2397 loc) · 114 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CSS Text Module Level 3 (CSS3 Text)</title>
<link rel=contents href="#contents">
<!--<link rel=index href="#index">-->
<link rel="stylesheet" type="text/css" href="../default.css">
<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 }
.char { border: 1px dotted gray; }
.quarter { font-size: 25%; }
tt[lang="ja"] { font-family: "MS Gothic", "Osaka", monospace }
div.figure table {
margin :auto;
}
</style>
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-ED.css">
</head>
<body>
<div class="head">
<!--logo-->
<h1>CSS Text Module Level 3</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
<dl>
<dt>This version:</dt>
<!--
<dd><a href="http://www.w3.org/TR/[YEAR]/WD-css3-text-[CDATE]/">http://www.w3.org/TR/[YEAR]/WD-css3-text-[CDATE]/</a></dd>
-->
<dd><a href="http://dev.w3.org/csswg/css3-text/">http://dev.w3.org/csswg/css3-text/</a>
8096
<dt>Latest version:</dt>
<dd><a href="http://www.w3.org/TR/css3-text/">http://www.w3.org/TR/css3-text/</a></dd>
<dt>Latest editor's draft:</dt>
<dd><a href="http://dev.w3.org/csswg/css3-text/">http://dev.w3.org/csswg/css3-text/</a></dd>
<dt>Previous version:</dt>
<dd><a
href="http://www.w3.org/TR/2012/WD-css3-text-20121113/">http://www.w3.org/TR/2012/WD-css3-text-20121113/</a>
<dt>Issues List:</dt>
<dd><a href="http://www.w3.org/Style/CSS/Tracker/products/10">http://www.w3.org/Style/CSS/Tracker/products/10</a>
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-text%5D%20feedback">www-style@w3.org</a>
with subject line &ldquo;<kbd>[css-text] <var>&hellip; message topic &hellip;</var></kbd>&rdquo;
(<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/">archives</a>)
<dt>Editors:</dt>
<dd><a href="http://fantasai.inkedblade.net/contact">Elika J. Etemad</a> (Mozilla)</dd>
<dd><a href="mailto:koji.a.ishii@mail.rakuten.com">Koji Ishii</a> (Rakuten, Inc.)</dd>
</dl>
<!--begin-copyright-->
<p>[Here will be included the file "../copyright.inc"]</p>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id="abstract">Abstract</h2>
<p>This CSS3 module defines properties for text manipulation and
specifies their processing model. It covers line breaking, justification
and alignment, white space handling, and text
transformation.</p>
<h2 class="no-num no-toc" id="status">Status of This Document</h2>
<p><em>This section describes the status of this document at the time of
its publication. Other documents may supersede this document. A list of
current W3C publications and the latest revision of this technical report
can be found in the <a href="http://www.w3.org/TR/">W3C technical reports
index at http://www.w3.org/TR/.</a></em>
<p>Publication as a Working Draft does not imply endorsement by the W3C
Membership. This is a draft document and may be updated, replaced or
obsoleted by other documents at any time. It is inappropriate to cite this
document as other than work in progress.
<p>This CSS module has been produced as a combined effort of the <a
href="http://www.w3.org/International/Activity">W3C Internationalization Activity</a>,
and the <a href="http://www.w3.org/Style/Activity">Style Activity</a> and is maintained
by the <a href="http://www.w3.org/Style/CSS/members">CSS Working Group</a>. It also
includes contributions made by participants in the <a
href="http://www.w3.org/Style/XSL/Group/">XSL Working Group</a> (<a
href="http://cgi.w3.org/MemberAccess/AccessRequest">members
only</a>).
<p>This document was produced by a group operating under the <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. W3C maintains a <a
href="http://www.w3.org/2004/01/pp-impl/32061/status"
rel=disclosure>public list of any patent disclosures</a> made in
connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</a>.</p>
<p><strong>Feedback on this draft should be posted to the
(<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
public mailing list <a href="mailto:www-style@w3.org">www-style@w3.org</a></strong>
(see <a href="http://www.w3.org/Mail/Request">instructions</a>) <strong>with
<kbd>[css3-text]</kbd> in the subject line.</strong>
You are strongly encouraged to complain if you see something stupid
in this draft. The editors will do their best to respond to all feedback.</p>
<p>The following features are at risk and may be cut from the spec during
its CR period if there are no (correct) implementations:</p>
<ul>
<li>the ''full-width'' value of 'text-transform'
<li>the &lt;length> values of the 'tab-size' property
<li>the ''start end'' value of 'text-align'
<li>the 'text-justify' property
<li>the percentage values of 'word-spacing'
<li>minimum and maximum limits of 'word-spacing' and 'letter-spacing'
<li>the 'hanging-punctuation' property
</ul>
<h2 class="no-num no-toc" id="contents">
Table of Contents</h2>
<!--toc-->
<h2 id="intro">
Introduction</h2>
<p>[document here]</p>
<p class="issue">This draft describes features that are specific to certain scripts.
There is an ongoing discussion about where these features belong: in
existing CSS properties, in new CSS properties, or perhaps in other
specifications.
<p class="note">
<a name="decoration"></a>
<a name="text-decoration"></a>
<a name="line-decoration"></a>
<a name="text-decoration-line"></a>
<a name="text-decoration-color"></a>
<a name="text-decoration-style"></a>
<a name="text-decoration-skip"></a>
<a name="text-underline-position"></a>
<a name="emphasis-marks"></a>
<a name="text-emphasis-style"></a>
<a name="text-emphasis-color"></a>
<a name="text-emphasis"></a>
<a name="text-emphasis-position"></a>
<a name="text-shadow"></a>
Text decoration has moved to
CSS Text Decoration Module Level 3
[[CSS3-TEXT-DECOR]].
<h3 id="placement">
Module Interactions</h3>
<p>This module replaces and extends the text-level
features defined in [[!CSS21]] chapter 16.
<h3 id="values">
Values</h3>
<p>This specification follows the
<a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
definition conventions</a> from [[!CSS21]]. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
Other CSS modules may expand the definitions of these value types: for
example [[CSS3COLOR]], when combined with this module, expands the
definition of the &lt;color&gt; value type as used in this specification.</p>
<p>In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the
<a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
keyword as their property value. For readability it has not been repeated
explicitly.
<h3 id="terms">
Terminology</h3>
<p id="grapheme-cluster">A <dfn>grapheme cluster</dfn> is what
a language user considers to be a character or a basic unit of the
script. The term is described in detail in the Unicode Technical
Report: Text Boundaries [[!UAX29]]. This specification uses the
<em>extended grapheme cluster</em> definition in [[!UAX29]] (not
the <em>legacy grapheme cluster</em> definition). The UA may further
tailor the definition as allowed by Unicode. Within this specification,
the ambiguous term <dfn>character</dfn> is used as a friendlier synonym
for <i>grapheme cluster</i>.
See <a href="http://dev.w3.org/csswg/css3-writing-modes/#character-properties">Characters and Properties</a>
for how to determine the Unicode properties of a character.
<p id="letter">A <dfn>letter</dfn> for the purpose of this specification
is a <i>character</i> belonging to one of the Letter or Number general
categories in Unicode. [[!UAX44]]
<p>The rendering characteristics of a <i>character</i> divided by an
element boundary is undefined: it 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 by
element boundaries may give inconsistent or undesired results.
<p>The <dfn>content language</dfn> of an element is the (human) language
the element is declared to be in, according to the rules of the
<a href="http://www.w3.org/TR/CSS21/conform.html#doclanguage">document language</a>.
For example, the rules for determining the <i>content language</i> of an HTML
element use the <code>lang</code> attribute and are defined in [[HTML5]],
and the rules for determining the <i>content language</i> of an XML element use
the <code>xml:lang</code> attribute and are
<a href="http://www.w3.org/TR/REC-xml/#sec-lang-tag">defined</a> in [[XML10]].
Note that it is possible for the <i>content language</i> of an element
to be unknown.
<p>Other terminology and concepts used in this specification are defined
in [[!CSS21]] and [[!CSS3-WRITING-MODES]].
<h2 id="transforming">
Transforming Text</h2>
<h3 id="text-transform">
<a name="caps-prop"></a>
Transforming Text: the 'text-transform' property</h3>
<table class="propdef">
<tr>
<th>Name:</th>
<td><dfn>text-transform</dfn></td>
</tr>
<tr>
<th><a href="#values">Value</a>:
<td>none | capitalize | uppercase | lowercase | full-width
</td>
</tr>
<tr>
<th>Initial:</th>
<td>none</td>
</tr>
<tr>
<th>Applies to:</th>
<td>all elements</td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed&#160;value:</th>
<td>as specified</td>
</tr>
</table>
<p>This property transforms text for styling purposes.
(It has no effect on the underlying content.)
Values have the following meanings:</p>
<dl>
<dt><dfn title="text-transform:none">''none''</dfn></dt>
<dd>No effects.</dd>
<dt><dfn title="text-transform:capitalize">''capitalize''</dfn></dt>
<dd>Puts the first <i>letter</i> of each word in titlecase; other characters
are unaffected.</dd>
<dt><dfn title="text-transform:uppercase">''uppercase''</dfn></dt>
<dd>Puts all <i>letters</i> in uppercase.
<dt><dfn title="text-transform:lowercase">''lowercase''</dfn></dt>
<dd>Puts all <i>letters</i> in lowercase.</dd>
<dt><dfn title="text-transform:full-width">''full-width''</dfn></dt>
<dd>Puts all characters in fullwidth form.
If the character does not have a corresponding fullwidth form,
it is left as is.
This value is typically used to typeset Latin characters and digits
like ideographic characters.
<!--
<dt><dfn title="text-transform:full-size-kana">''full-size-kana''</dfn></dt>
<dd>Converts all small Kana characters to normal Kana.
The mappings for small Kana to normal Kana are defined in
<a href="#small-kana">Small Kana Mappings</a>.</p>
<p class=note>
This value is typically used for ruby annotation text,
where due to the small type size, small Kana
is often drawn as large Kana.
This value allows such underlying text to use correct orthography
so that it is accessible and can be styled correctly
when not presented as ruby.
-->
</dl>
<p>The case mapping rules for the character repertoire specified by the
Unicode Standard can be found on the Unicode Consortium Web site
[[!UNICODE]]. The UA must use the full case mappings for Unicode
characters, including any conditional casing rules, as defined in
Default Case Algorithm section. If (and only if) the <i>content language</i>
of the element is, according to the rules of the
<a href="http://www.w3.org/TR/CSS21/conform.html#doclanguage">document language</a>,
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>.
<div class="example">
<p>For example, in Turkish there are two &ldquo;i&rdquo;s, one with
a dot&mdash;&ldquo;İ&rdquo; and &ldquo;i&rdquo;&mdash; and one
without&mdash;&ldquo;I&rdquo; and &ldquo;ı&rdquo;. Thus the usual
case mappings between &ldquo;I&rdquo; and &ldquo;i&rdquo; are
replaced with a different set of mappings to their respective
undotted/dotted counterparts, which do not exist in English. This
mapping must only take effect if the <i>content language</i> is Turkish
(or another Turkic language that uses Turkish casing rules);
in other languages, the usual mapping of &ldquo;I&rdquo;
and &ldquo;i&rdquo; is required. This rule is thus conditionally
defined in Unicode's SpecialCasing.txt file.
</div>
<!--
<div class="example">
<p>An example where the UA may choose to include rules beyond those
in Unicode is Greek. In Greek, if the entire word is in upper case
(''text-transform: capitalize'' vs. ''text-transform: uppercase''),
accents are dropped or transformed according to language-specific rules.
http://blogs.msdn.com/b/michkap/archive/2006/08/18/706383.aspx
</div>
-->
<p>The definition of "word" used for ''capitalize'' is UA-dependent;
[[!UAX29]] is suggested (but not required) for determining such word
boundaries. Authors should not expect ''capitalize'' to follow
language-specific titlecasing conventions (such as skipping articles
in English).
<p>The definition of fullwidth and halfwidth forms can be found on the
Unicode consortium web site at [[!UAX11]].
The mapping to fullwidth form is defined by taking code points with
the &lt;wide&gt; or the &lt;narrow&gt; tag in their Decomposition_Mapping
in [[!UAX44]]. For the &lt;narrow&gt; tag, the mapping is from the code
point to the decomposition (minus &lt;narrow&gt; tag), and for the
&lt;wide&gt; tag, the mapping is from the decomposition (minus the
&lt;wide&gt; tag) back to the original code point.</p>
<p>Text transformation happens after <a href="#white-space-rules">white
space processing</a>, which means that ''full-width'' transforms
only preserved U+0020 spaces to U+3000.
<div class="example">
<p>The following example converts the ASCII characters in abbreviations
in Japanese to their fullwidth variants so that they lay out and line
break like ideographs:
<pre>abbr:lang(ja) { text-transform: full-width; }</pre>
</div>
<p class="note">
A future level of CSS may introduce the ability to create custom mapping
tables for less common text transforms, such as by an ''@text-transform''
rule similar to ''@counter-style'' from [[CSS-COUNTER-STYLES-3]].
<!--
This mechanism may be used to replace ''full-size-kana''. This would
require authors needing this functionality to copy out the conversion
tables, however.
-->
<h2 id="white-space"><a id="white-space-collapsing"></a><a id='text-wrap'></a>
White Space and Wrapping: the 'white-space' property</h2>
<p>This property specifies two things:
<ul>
<li>whether and how <a href="#white-space-processing">white space</a> inside the element is collapsed
<li>whether lines may <i>wrap</i> at unforced <i>soft wrap opportunities</i>
</ul>
<table class="propdef">
<tr>
<th>Name:</th>
<td><dfn>white-space</dfn></td>
</tr>
<tr>
<th><a href="#values">Value</a>:
<td>normal | pre | nowrap | pre-wrap | pre-line</td>
</tr>
<tr>
<th>Initial:</th>
<td>not defined for shorthand properties</td>
</tr>
<tr>
<th>Applies to:</th>
<td>all elements</td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed&#160;value:</th>
<td>see individual properties</td>
</tr>
</table>
<p>Values have the following meanings, which must be interpreted
according to
the <a href="#white-space-rules">White Space Processing</a> and
<a href="#line-breaking">Line Breaking</a> rules:</p>
<dl>
<dt><dfn title="white-space:normal">''normal''</dfn></dt>
<dd>This value directs user agents to collapse sequences of white space
into a single character (or <a href="#line-break-transform">in some
cases</a>, no character).
Lines may wrap at allowed <i>soft wrap opportunities</i>,
as determined by the line-breaking rules in effect,
in order to minimize overflow.
<dt><dfn title="white-space:pre">''pre''</dfn></dt>
<dd>This value prevents user agents from collapsing sequences of white space.
<i>Segment breaks</i> such as line feeds and carriage returns are preserved as <i>forced line breaks</i>.
Lines only break at <i>forced line breaks</i>;
content that does not fit within the block container overflows it.
<dt><dfn title="white-space:nowrap">''nowrap''</dfn>
<dd>Like ''normal'', this value collapses white space;
but like ''pre'', it does not allow wrapping.
<dt><dfn title="white-space:pre-wrap">''pre-wrap''</dfn></dt>
<dd>Like ''pre'', this value preserves white space;
but like ''normal'', it allows wrapping.
<dt><dfn title="white-space:pre-line">''pre-line''</dfn></dt>
<dd>Like ''normal'', this value collapses consecutive spaces and allows wrapping,
but preserves <i>segment breaks</i> in the source as <i>forced line breaks</i>.
</dl>
<p>The following informative table summarizes the behavior of various
'white-space' values:</p>
<table class="data">
<colgroup class="header"></colgroup>
<colgroup span=3></colgroup>
<thead>
<tr>
<th></th>
<th>New Lines</th>
<th>Spaces and Tabs</th>
<th>Text Wrapping</th>
</tr>
</thead>
<tbody>
<tr>
<th>''normal''</th>
<td>Collapse</td>
<td>Collapse</td>
<td>Wrap</td>
</tr>
<tr>
<th>''pre''</th>
<td>Preserve</td>
<td>Preserve</td>
<td>No wrap</td>
</tr>
<tr>
<th>''nowrap''</th>
<td>Collapse</td>
<td>Collapse</td>
<td>No wrap</td>
</tr>
<tr>
<th>''pre-wrap''</th>
<td>Preserve</td>
<td>Preserve</td>
<td>Wrap</td>
</tr>
<tr>
<th>''pre-line''</th>
<td>Preserve</td>
<td>Collapse</td>
<td>Wrap</td>
</tbody>
</table>
<p>See <a href="#white-space-processing">White Space Processing Rules</a>
for details on how white space collapses. An informative summary of
collapsing (''normal'' and ''nowrap'') is presented below:
<ul>
<li>A sequence of segment breaks and other white space between two
Chinese, Japanese, or Yi characters collapses into nothing.
<li>A zero width space before or after a white space sequence
containing a segment break causes the entire sequence of white space
to collapse into a zero width space.
<li>Otherwise, consecutive white space collapses into a single space.
</ul>
<p>See <a href="#line-breaking">Line Breaking</a>
for details on wrapping behavior.
<h2 id="white-space-processing">
White Space Processing Details</h2>
<p>The source text of a document often contains formatting
that is not relevant to the final rendering: for example,
<a href="http://rhodesmill.org/brandon/2012/one-sentence-per-line/"
>breaking the source into segments</a> (lines) for ease of editing
or adding white space characters such as tabs and spaces to indent the source code.
CSS white space processing allows the author to control interpretation of such formatting:
to preserve or collapse it away when rendering the document.
White space processing in CSS interprets white space characters only for rendering:
it has no effect on the underlying document data.
<p>White space processing in CSS is controlled with the 'white-space' property.
<p id="segment-normalization">
CSS does not define document segmentation rules. Segments could be
separated by a particular newline seqence (such as a line feed or
CRLF pair), or delimited by some other mechanism, such as the SGML
RECORD-START and RECORD-END tokens.
For CSS processing, each document language&ndash;defined segment break,
CRLF sequence (U+000D U+000A), carriage return (U+000D), and line feed (U+000A)
in the text is treated as a <dfn>segment break</dfn>,
which is then interpreted for rendering as specified by the 'white-space' property.
<p class="note">Note that the document parser may have not only normalized
any segment breaks, but also collapsed other space characters or
otherwise processed white space according to markup rules. Because CSS
processing occurs <em>after</em> the parsing stage, it is not possible
to restore these characters for styling. Therefore, some of the
behavior specified below can be affected by these limitations and
may be user agent dependent.</p>
<p class="note">Note that anonymous inlines consisting entirely of
<i>collapsible</i> white space are removed from the rendering tree.
See [[CSS21]] section
<a href="http://www.w3.org/TR/CSS21/visuren.html#anonymous">9.2.2.1</a></p>
<p>Control characters (Unicode class Cc) other than tab (U+0009), line feed
(U+000A), and carriage return (U+000D)
are ignored for the purpose of rendering.
<h3 id="white-space-rules">
The White Space Processing Rules</h3>
<p>White space processing affects only spaces (U+0020), tabs (U+0009),
and <a href="#segment-normalization">segment breaks</a>.
<p>For each inline (including anonymous inlines) within an inline
formatting context, white space characters are handled as follows,
ignoring bidi formatting characters as if they were not there:</p>
<ul>
<li id="collapse"><p>If 'white-space' is set to
''normal'', ''nowrap'', or ''pre-line'',
white space characters are considered <dfn>collapsible</dfn>
and are processed by performing the following steps:</p>
<ol>
<li>All spaces and tabs immediately preceding or following a segment
break are removed.</li>
<li>Segment breaks are transformed for
rendering according to the <a href="#line-break-transform">line
break transformation rules</a>.
</li>
<li>Every tab is converted to a space (U+0020).</li>
<li>Any space immediately following another collapsible space
&mdash;even one outside the boundary of the inline containing
the space, provided they are within the same inline formatting
context&mdash;is collapsed to have zero advance width. (It is
invisible, but retains its <i>soft wrap opportunity</i>, if any.)</li>
</ol>
</li>
<li><p>If 'white-space' is set to ''pre-wrap'', any sequence of
spaces is treated as a sequence of non-breaking spaces. However,
a <i>soft wrap opportunity</i> exists at the end of the sequence.</p></li>
</ul>
<p>Then, the entire block is rendered. Inlines are laid out, taking bidi
reordering into account, and <i>wrapping</i> as specified by the
'white-space' property.</p>
<p>As each line is laid out,</p>
<ol>
<li>A sequence of collapsible spaces at the beginning of a line is
removed.
<li>Each tab is rendered as a horizontal shift
that lines up the start edge of the next glyph with the next tab stop.
<dfn>Tab stops</dfn> occur at points that are multiples of the <i>tab size</i>
from the block's starting content edge.
The <dfn>tab size</dfn> is given by the 'tab-size' property.
<li>A sequence of <i>collapsible</i> spaces at the end of a line is removed.
<li>If spaces or tabs at the end of a line are non-collapsible but
have 'text-wrap' set to 'normal' the UA may visually
collapse their character advance widths.
</ol>
<p>White space that was not removed or collapsed during the white space
processing steps is called <dfn>preserved</dfn> white space.</p>
<div class="example">
<h4 id="egbidiwscollapse">
Example of bidirectionality with white space collapsing</h4>
<p>Consider 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">&#160;</span>&lt;rtl&gt;<span class="egbidiwsbB">&#160;</span>B<span class="egbidiwsaB">&#160;</span>&lt;/rtl&gt;<span class="egbidiwsbC">&#160;</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. If the 'text-space-collapse' property is set
to ''collapse'', 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">&#160;</span>)
would collapse with the space after the A (<span
class="egbidiwsaA">&#160;</span>).</li>
<li>The space before the C (<span class="egbidiwsbC">&#160;</span>)
would collapse with the space after the B (<span
class="egbidiwsaB">&#160;</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 ordered according to the Unicode bidirectional
algorithm, with the end result being:</p>
<pre>A<span class="egbidiwsaA">&#160;</span><span class="egbidiwsaB">&#160;</span>BC</pre>
<p>Note that there are two spaces between A and B, and none between B
and C. This is best avoided by putting spaces outside the element
instead of just inside the opening and closing tags and, where
practical, by relying on implicit bidirectionality instead of explicit
embedding levels.</p>
</div>
<h4 id="line-break-transform">
Line Break Transformation Rules</h4>
<p>When 'white-space' is ''pre'', ''pre-wrap'', or ''pre-line'',
<i>segment breaks</i> are not <i>collapsible</i>
and are instead transformed into a preserved line feed (U+000A).
<p>For other values of 'white-space', <i>segment breaks</i> are <i>collapsible</i>,
and are either transformed into a space (U+0020) or removed
depending on the context before and after the break:</p>
<ul>
<li>If the character immediately before or immediately after the segment
break is the zero-width space character (U+200B), then the break
is removed, leaving behind the zero-width space.
<li>Otherwise, if the East Asian Width property [[!UAX11]] of both
the character before and after the line feed is F, W, or H (not A),
and neither side is Hangul, then the segment break is removed.
<li>Otherwise, the segment break is converted to a space (U+0020).
</ul>
<p class="note">Note that the white space processing rules have already
removed any tabs and spaces after the segment break before these checks
take place.</p>
<p class="issue">Comments on how well this would work in practice would
be very much appreciated, particularly from people who work with
Thai and similar scripts.
Note that browser implementations do not currently follow these rules
(although IE does in some cases transform the break).</p>
<h3 id="tab-size">
Tab Character Size: the 'tab-size' property</h3>
<table class="propdef">
<tr>
<th>Name:</th>
<td><dfn>tab-size</dfn></td>
</tr>
<tr>
<th><a href="#values">Value</a>:
<td>&lt;integer&gt; | &lt;length&gt;</td>
</tr>
<tr>
<th>Initial:</th>
<td>8</td>
</tr>
<tr>
<th>Applies to:</th>
<td>block containers</td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed&#160;value:</th>
<td>the specified integer or length made absolute</td>
</tr>
</table>
<p>This property determines the <i>tab size</i> used to render preserved tab characters (U+0009).
Integers represent the measure as multiples of the space character's advance width (U+0020).
Negative values are not allowed.
<h2 id="line-breaking">
Line Breaking and Word Boundaries</h2>
<p>When inline-level content is laid out into lines, it is broken across line boxes.
Such a break is called a <dfn>line break</dfn>.
When a line is broken due to explicit line-breaking controls,
or due to the start or end of a block,
it is a <dfn>forced line break</dfn>.
When a line is broken due to content <dfn title="wrapping|wrap">wrapping</dfn>
(i.e. when the UA creates unforced line breaks in order to fit the content within the measure),
it is a <dfn>soft wrap break</dfn>.
The process of breaking inline-level content into lines is called <dfn>line breaking</dfn>.
<p>Wrapping is only performed at an allowed break point, called a <dfn>soft wrap opportunity</dfn>.
<p>In most writing systems,
in the absence of hyphenation a <i>soft wrap opportunity</i> occurs only at word boundaries.
Many such systems use spaces or punctuation to explicitly separate words,
and <i>soft wrap opportunities</i> can be identified by these characters.
Scripts such as Thai, Lao, and Khmer, however,
do not use spaces or punctuation to separate words.
Although the zero width space (U+200B) can be used as an explicit word delimiter in these scripts,
this practice is not common.
As a result, a lexical resource is needed to correctly identify <i>soft wrap opportunities</i> in such texts.
<p>In several other writing systems, (including Chinese, Japanese, Yi, and sometimes also Korean)
a <i>soft wrap opportunity</i> is based on syllable boundaries, not word boundaries.
In these systems a line can break anywhere <em>except</em> between certain character combinations.
Additionally the level of strictness in these restrictions can vary with the typesetting style.</p>
<p>CSS does not fully define where <i>soft wrap opportunities</i> occur,
however some controls are provided to distinguish common variations.
<div class="note">
<p>Further information on line breaking conventions can be found in
[[JLREQ]] and [[JIS4051]] for Japanese,
[[ZHMARK]] for Chinese, and
in [[!UAX14]] for all scripts in Unicode.
<!-- The CSS Working Group notes that although UAX 14 contains a wealth of
information about line breaking conventions, a literal implementation
of its algorithm has been found to be inadequate in multiple situations. -->
<p class="issue">Any guidance for appropriate references here would be
much appreciated.
<!-- Additionally, some guidance could be provided on how
to break or not break Southeast Asian in the absence of a dictionary.
(See e.g. <a href="http://lists.w3.org/Archives/Public/www-style/2011Feb/0126.html">notes on Thai</a>.) -->
</div>
<h3 id="line-break-details">
Line Breaking Details</h3>
<p>When determining <i>line breaks</i>:
<ul>
<li>Regardless of the 'white-space' value,
lines always break at each <i>preserved</i> forced break character:
for all values, line-breaking behavior defined for
the BK, CR, LF, CM, NL, and SG line breaking classes in [[!UAX14]]
must be honored.
<li>When 'white-space' allows wrapping,
line breaking behavior defined for the WJ, ZW, and GL line-breaking classes in [[!UAX14]]
must be honored.
<li>UAs that allow wrapping at punctuation other than spaces should prioritize breakpoints.
For example, if breaks after slashes are given a lower priority than spaces,
the sequence "check /etc" will never break between the '/' and the 'e'.
The UA may use the width of the containing block, the text's language,
and other factors in assigning priorities.
As long as care is taken to avoid such awkward breaks, allowing breaks at
appropriate punctuation other than spaces is recommended, as it results
in more even-looking margins, particularly in narrow measures.
<li>Out-of-flow elements do not introduce a <i>forced line break</i>
or <i>soft wrap opportunity</i> in the flow.
<li>The line breaking behavior of a replaced element or other atomic inline
is equivalent to that of the Object Replacement Character (U+FFFC).
<li>For <i>soft wrap opportunities</i> created by characters that disappear at the line break (e.g. U+0020 SPACE),
properties on the element containing that character control the line breaking at that opportunity.
For <i>soft wrap opportunities</i> defined by the boundary between two characters,
the properties on the element containing the boundary control breaking.
<!-- http://lists.w3.org/Archives/Public/www-style/2008Dec/0043.html -->
<li>For <i>soft wrap opportunities</i> before the first or after the last character of a box,
the break occurs immediately before/after the box (at its margin edge)
rather than breaking the box between its content edge and the content.
<li>For line breaking in/around <a href="http://www.w3.org/TR/css3-ruby/">ruby</a>,
the base text is considered part of the same inline formatting context as its surrouding content,
but the ruby text is not:
i.e. line breaking opportunities between the ruby element and its surrounding content
are determined as if the ruby base were inline and the ruby text were not there.
</ul>
<h3 id="line-break">
Breaking Rules for Punctuation: the 'line-break' property</h3>
<table class="propdef">
<tr>
<th>Name:</th>
<td><dfn>line-break</dfn></td>
</tr>
<tr>
<th><a href="#values">Value</a>:
<td>auto | loose | normal | strict</td>
</tr>
<tr>
<th>Initial:</th>
<td>auto</td>
</tr>
<tr>
<th>Applies to:</th>
<td>all elements</td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed&#160;value:</th>
<td>specified value</td>
</tr>
</table>
<p>This property specifies the strictness of line-breaking rules applied
within an element:
particularly how <i>wrapping</i> interacts with punctuation and symbols.
Values have the following meanings:</p>
<dl>
<dt><dfn title="line-break:auto">''auto''</dfn></dt>
<dd>The UA determines the set of line-breaking restrictions to use,
and it may vary the restrictions based on the length of the line; e.g.,
use a less restrictive set of line-break rules for short lines.</dd>
<dt><dfn title="line-break:loose">''loose''</dfn></dt>
<dd>Breaks text using the least restrictive set of line-breaking
rules. Typically used for short lines, such as in newspapers.</dd>
<dt><dfn title="line-break:normal">''normal''</dfn></dt>
<dd>Breaks text using the most common set of line-breaking rules.</dd>
<dt><dfn title="line-break:strict">''strict''</dfn></dt>
<dd>Breaks text using the most stringent set of line-breaking
rules.</dd>
</dl>
<p>CSS distinguishes between three levels of strictness in the rules for
text wrapping.
The precise set of rules in effect for each level is up to the UA
and should follow language conventions.
However, this specification does require that:</p>
<ul>
<li>Following breaks be forbidden in ''strict'' line breaking and
allowed in ''normal'' and ''loose'':
<ul>
<li>breaks before Japanese small kana or the Katakana-Hiragana prolonged sound mark:
i.e. characters with the Unicode Line Break property <code>CJ</code>.
(See <a href="http://www.unicode.org/Public/UNIDATA/LineBreak.txt">LineBreak.txt</a> in [[!UNICODE]].)
</ul>
If the <i>content language</i> is Chinese, Japanese, or Korean, then additionally:
<ul>
<li>breaks before hyphens:<br>
&#x2010;&nbsp;U+2010, &#x2013;&nbsp;U+2013, &#x301C;&nbsp;U+301C,
&#x30A0;&nbsp;U+30A0
</ul>
<li>Following breaks be forbidden in ''normal'' and ''strict'' line
breaking and allowed in ''loose'':
<ul>
<li>breaks before iteration marks:<br>
&#x3005;&nbsp;U+3005, &#x303B;&nbsp;U+303B, &#x309D;&nbsp;U+309D,
&#x309E;&nbsp;U+309E, &#x30FD;&nbsp;U+30FD, &#x30FE;&nbsp;U+30FE
<li>breaks between some inseparable characters:<br>
&#x2025;&nbsp;U+2025, &#x2026;&nbsp;U+2026
</ul>
If the <i>content language</i> is Chinese, Japanese, or Korean, then additionally:
<ul>
<li>breaks before certain centered punctuation marks:<br>
&#x003A;&nbsp;U+003A, &#x003B;&nbsp;U+003B, &#x30FB;&nbsp;U+30FB,
&#xFF1A;&nbsp;U+FF1A, &#xFF1B;&nbsp;U+FF1B, &#xFF65;&nbsp;U+FF65,
&#x0021;&nbsp;U+0021, &#x003F;&nbsp;U+003F, &#x203C;&nbsp;U+203C,
&#x2047;&nbsp;U+2047, &#x2048;&nbsp;U+2048, &#x2049;&nbsp;U+2049,
&#xFF01;&nbsp;U+FF01, &#xFF1F;&nbsp;U+FF1F
<li>breaks before suffixes:<br>
&#x0025;&nbsp;U+0025, &#x00A2;&nbsp;U+00A2, &#x00B0;&nbsp;U+00B0,
&#x2030;&nbsp;U+2030, &#x2032;&nbsp;U+2032, &#x2033;&nbsp;U+2033,
&#x2103;&nbsp;U+2103, &#xFF05;&nbsp;U+FF05, &#xFFE0;&nbsp;U+FFE0
<li>breaks after prefixes:<br>
&#x2116;&nbsp;U+2116
and all currency symbols (Unicode general category Sc) other than
&#x00A2;&nbsp;U+00A2 and &#xFFE0;&nbsp;U+FFE0
</ul>
</ul>
<p class="issue">
These rules should be cross-checked against <a href="http://www.w3.org/TR/jlreq/#possibilities_for_linebreaking_between_characters">JLREQ</a>
and any differences verified.
<p class="note">In the recommended list above, no distinction is made among the levels of
strictness in non-CJK text: only CJK codepoints are affected, unless
the text is marked as Chinese or Japanese, in which case some additional
common codepoints are affected. However a future level of CSS may add
behaviors affecting non-CJK text.
<p class="note">The CSSWG recognizes that in a future edition of the
specification finer control over line breaking may be necessary to
satisfy high-end publishing requirements.
<h3 id="word-break">
Breaking Rules for Letters: the 'word-break' property</h3>
<table class="propdef">
<tr>
<th>Name:</th>
<td><dfn>word-break</dfn></td>
</tr>
<tr>
<th><a href="#values">Value</a>:
<td>normal | keep-all | break-all</td>
</tr>
<tr>
<th>Initial:</th>
<td>normal</td>
</tr>
<tr>
<th>Applies to:</th>
<td>all elements</td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed&#160;value:</th>
<td>specified value</td>
</tr>
</table>
<p>This property specifies <i>soft wrap opportunities</i> between letters.
Values have the following meanings:</p>
<dl>
<dt><dfn title="word-break:normal">''normal''</dfn></dt>
<dd>Words break according to their usual rules.</dd>
<dt><dfn title="word-break:break-all">''break-all''</dfn></dt>
<dd>In addition to ''normal'' <i>soft wrap opportunities</i>,
lines may break between any two <i>letters</i>
(except where forbidden by the 'line-break' property).
Hyphenation is not applied. This option is used mostly in a context where
the text is predominantly using CJK characters with few non-CJK excerpts
and it is desired that the text be better distributed on each line.</dd>
<dt><dfn title="word-break:keep-all">''keep-all''</dfn></dt>
<dd>
Implicit <i>soft wrap opportunities</i> between <i>letters</i> are suppressed,
i.e. breaks are prohibited between pairs of letters
(including those explicitly allowed by 'line-break')
except where opportunities exist due to dictionary-based breaking.
Otherwise this option is equivalent to ''normal''.
In this style, sequences of CJK characters do not break.
<p class=note>This is sometimes seen in Korean (which uses spaces between words),
and is also useful for mixed-script text where CJK snippets are mixed