Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
6767 lines (6150 sloc) 283 KB
<pre class='metadata'>
Title: CSS Text Module Level 3
Shortname: css-text
Level: 3
Status: ED
Work Status: Refining
Group: csswg
ED: https://drafts.csswg.org/css-text-3/
TR: https://www.w3.org/TR/css-text-3/
Previous version: https://www.w3.org/TR/2020/WD-css-text-3-20200429/
Previous version: https://www.w3.org/TR/2019/WD-css-text-3-20191113/
Previous Version: https://www.w3.org/TR/2018/WD-css-text-3-20181212/
Previous Version: https://www.w3.org/TR/2018/WD-css-text-3-20181206/
Previous Version: https://www.w3.org/TR/2018/WD-css-text-3-20180920/
Previous Version: https://www.w3.org/TR/2017/WD-css-text-3-20170822/
Previous Version: https://www.w3.org/TR/2013/WD-css-text-3-20131010/
Previous Version: https://www.w3.org/TR/2012/WD-css3-text-20121113/
Issue Tracking: Tracker http://www.w3.org/Style/CSS/Tracker/products/10
Test Suite: http://test.csswg.org/suites/css3-text/nightly-unstable/
Editor: Elika J. Etemad / fantasai, Invited Expert, http://fantasai.inkedblade.net/contact, w3cid 35400
Editor: Koji Ishii, Invited Expert, kojiishi@gluesoft.co.jp, w3cid 45369
Editor: Florian Rivoal, Invited Expert, https://florian.rivoal.net, w3cid 43241
Abstract: This CSS module defines properties for text manipulation and specifies their processing model. It covers line breaking, justification and alignment, white space handling, and text transformation.
At Risk: the ''full-width'' value of 'text-transform'
At Risk: the ''full-size-kana'' value of 'text-transform'
At Risk: the &lt;length> values of the 'tab-size' property
At Risk: the 'text-justify' property
At Risk: the percentage values of 'word-spacing'
At Risk: the 'hanging-punctuation' property
At Risk: Writing-system specific adjustments to line-breaking
At Risk: Trimming trailing Ogham space marks
Ignored Vars: letter-spacing
Status Text: This publication partially addresses the issues in the <a href="https://drafts.csswg.org/css-text-3/issues-lc-2013">disposition of comments</a> since the <a href="https://www.w3.org/TR/2013/WD-css-text-3-20131010/">October 2013 Last Call Working Draft</a>, and, while a marked improvement over the previous draft, is not considered to be entirely up-to-date at the time of publication. A completed dispostion of comments and corresponding draft will be published once the issues are fully addressed and reviewed by the CSSWG and Internationalization WG.
WPT Path Prefix: /css/css-text/
</pre>
<pre class=link-defaults>
spec:css-display-3; type:property; text:display
spec:css-fonts-4; type:property; text:font-feature-settings
</pre>
<style type="text/css">
img { vertical-align: middle; }
span[lang] { font-size: 125%; line-height: 1; vertical-align: middle;}
/* Bidi & spaces example */
.egbidiwsaA,.egbidiwsbB,.egbidiwsaB,.egbidiwsbC
{ white-space:pre;font-size:80%;font-family:monospace; vertical-align:2px; margin:1px }
.egbidiwsaA { background:lime;padding:2px; }
.egbidiwsbB { border:2px solid blue }
.egbidiwsaB { background:yellow;border:2px dotted white }
.egbidiwsbC { border:2px dotted red }
.hyphens-ex {
border: thin solid black;
display: inline-block;
padding: 4pt;
}
/* Start Letter-spacing Tutorial */
.ls-ex {
font-size: 200%;
margin-left: 1em;
margin-right: 1em;
}
.ls-fixed-width {
width: 10em;
}
.color-box { background: rgb(224, 203, 82); }
.bad { color: red; }
.good { color: green; }
/* End Letter-spacing Tutorial */
.char { border: 1px dotted gray; }
.quarter { font-size: 25%; }
tt[lang="ja"] { font-family: "MS Gothic", "Osaka", monospace }
div.figure table {
margin :auto;
}
.feedback {
background: #FFEECC;
border-color: orange;
}
.feedback:before {
content: "Info Needed";
color: #FF8800;
}
.data .no { color: red; }
.data .ok { color: green; }
.data th em { display: block; font-size: smaller; font-weight: normal; font-style: italic; }
</style>
<h2 id="intro">
Introduction</h2>
<p>This module describes the typesetting controls of CSS;
that is, the features of CSS that control the translation of
source text to formatted, line-wrapped text.
Various CSS properties provide control over
<a href="#transforming">case transformation</a>,
<a href="#white-space">white space collapsing</a>,
<a href="#white-space">text wrapping</a>,
<a href="#line-breaking">line breaking rules</a>
and <a href="#hyphenation">hyphenation</a>,
<a href="#justification">alignment and justification</a>,
<a href="#spacing">spacing</a>,
and <a href="#edge-effects">indentation</a>.
<div class="note">
<p>Note: Font selection is covered in <a href="https://www.w3.org/TR/css-fonts-3/">CSS Fonts Level 3</a> [[CSS-FONTS-3]].
<p>
<span id="decoration"></span>
<span id="text-decoration"></span>
<span id="line-decoration"></span>
<span id="text-decoration-line"></span>
<span id="text-decoration-color"></span>
<span id="text-decoration-style"></span>
<span id="text-decoration-skip"></span>
<span id="text-underline-position"></span>
<span id="emphasis-marks"></span>
<span id="text-emphasis-style"></span>
<span id="text-emphasis-color"></span>
<span id="text-emphasis"></span>
<span id="text-emphasis-position"></span>
<span id="text-shadow"></span>
Features for decorating text,
such as <a href="https://www.w3.org/TR/css-text-decor-3/#line-decoration">underlines</a>,
<a href="https://www.w3.org/TR/css-text-decor-3/#emphasis-marks">emphasis marks</a>,
and <a href="https://www.w3.org/TR/css-text-decor-3/#text-shadow-property">shadows</a>,
(previously part of this module)
are covered in
<a href="https://www.w3.org/TR/css-text-decor-3/">CSS Text Decoration Level 3</a> [[CSS-TEXT-DECOR-3]].
<p><a href="https://www.w3.org/TR/css-writing-modes-3/#text-direction">Bidirectional</a> and
<a href="https://www.w3.org/TR/css-writing-modes-3/#vertical-intro">vertical</a> text
are addressed in
<a href="https://www.w3.org/TR/css-writing-modes-3/">CSS Writing Modes Level 3</a> [[CSS-WRITING-MODES-3]].
</div>
Further information about the typesetting requirements
of various languages and writing systems around the world
can be found in the <a href="https://www.w3.org/International/core/">Internationalization Working Group</a>’s
<a href="https://www.w3.org/TR/typography/">Typography Index</a>.
[[TYPOGRAPHY]]
<h3 id="placement">
Module Interactions</h3>
<p>This module, together with [[CSS-TEXT-DECOR-3]],
replaces and extends the text-level features defined in [[!CSS2]] chapter 16.
<p>In addition to the terms defined below,
other terminology and concepts used in this specification are defined
in [[!CSS2]] and [[!CSS-WRITING-MODES-3]].
<h3 id="values">
Value Definitions</h3>
This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]]
using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from [[!CSS-VALUES-3]].
Value types not defined in this specification are defined in CSS Values &amp; Units [[!CSS-VALUES-3]].
Combination with other CSS modules may expand the definitions of these value types.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification
also accept the <a>CSS-wide keywords</a> as their property value.
For readability they have not been repeated explicitly.
<h3 id="languages">
Languages and Typesetting</h3>
<p class="advisement"><strong>
Authors should accurately language-tag their content for the best typographic behavior.
</strong>
Many typographic effects vary by linguistic context.
Language and writing system conventions can affect
line breaking, hyphenation, justification, glyph selection,
and many other typographic effects.
<strong>In CSS, language-specific typographic tailorings
are only applied when the <a>content language</a> is known (declared).</strong>
Therefore,
higher quality typography requires authors to communicate to the UA
the correct linguistic context of the text in the document.
The <dfn export>content language</dfn> of an element is the (human) language
the element is declared to be in, according to the rules of the
<a href="https://www.w3.org/TR/CSS2/conform.html#doclanguage">document language</a>.
Note that it is possible for the <a>content language</a> of an element
to be unknown--
e.g. untagged content,
or content in a <a>document language</a> that does not have a language-tagging facility
is considered to have an unknown <a>content language</a>.
Note: Authors can declare the [=content language=]
using the global <code>lang</code> attribute in HTML
or the universal <code>xml:lang</code> attribute in XML.
See the <a href="https://html.spec.whatwg.org/multipage/dom.html#language">rules
for determining the content language of an HTML element</a> in [[HTML]],
and the <a href="https://www.w3.org/TR/REC-xml/#sec-lang-tag">rules
for determining the content language of an XML element</a> in [[XML10]].
The [=content language=] an element is declared to be in
also identifies the specific written form of that language used in that element,
known as the <dfn export local-lt="writing system">content writing system</dfn>.
Depending on the [=document language=]'s facilities for identifying the [=content language=],
this information can be explicit or implied.
See the normative [[#script-tagging]].
Note: Some languages have more than one writing system tradition;
in other cases a language can be transliterated into a foreign writing system.
Authors should <a href="#script-tagging">subtag</a> such cases
so that the UA can adapt appropriately.
<!--
<div class=example>
For example, Korean (<code>ko</code>) can be written in
Hangul (<code>-Hang</code>),
Hanja (<code>-Hani</code>),
or a combination (<code>-Kore</code>).
Historical documents written solely in Hanja
do not use word spaces and
are formatted more like modern Chinese than modern Korean.
In other words, for typographic purposes <code>ko-Hani</code>
behaves more like <code>zh-Hant</code>
than <code>ko</code> (<code>ko-Kore</code>).
As another example Japanese (<code>ja</code>) is typically written
in a combination (<code>-Japn</code>) of Hiragana (<code>-Hira</code>),
Katakana (<code>-Kana</code>), and Kanji (<code>-Hani</code>).
However, it can also be ”romanized” into Latin (<code>-Latn</code>)
for special purposes like language-learning textbooks,
in which case it should be formatted more like English than Japanese.
As a third example contemporary Mongolian is written in two scripts:
Cyrillic (<code>-Cyrl</code>, officially used in Mongolia)
and Mongolian (<code>-Mong</code>, more common in Inner Mongolia, part of China).
These have very different formatting requirements,
with Cyrillic behaving similar to Latin and Greek,
and Mongolian deriving from both Arabic and Chinese writing conventions.
</div>
-->
<h3 id="characters">
Characters and Letters</h3>
<p>The basic unit of typesetting is the <dfn export>character</dfn>.
However, because writing systems are not always as simple as the basic English alphabet,
what a <a>character</a> actually is depends on the context in which the term is used.
For example, in Hangul (the Korean writing system),
each square representation of a syllable
(e.g. <span lang=ko-hang title="Hangul syllable HAN"></span>=<span lang=ko-Latn>Han</span>)
can be considered a <a>character</a>.
However, the square symbol is really composed of multiple letters each representing a phoneme
(e.g. <span lang=ko-hang title="Hangul letter HIEUH"></span>=<span lang=ko-Latn>h</span>,
<span lang=ko-hang title="Hangul letter HIEUH"></span>=<span lang=ko-Latn>a</span>,
<span lang=ko-hang title="Hangul letter HIEUH"></span>=<span lang=ko-Latn>n</span>)
and these also could each be considered a <a>character</a>.
<p>A basic unit of computer text encoding, for any given encoding,
is also called a <a>character</a>,
and depending on the encoding,
a single encoding <a>character</a> might correspond
to the entire pre-composed syllabic <a>character</a> (e.g. <span lang=ko-hang title="Hangul syllable HAN"></span>),
to the individual phonemic <a>character</a> (e.g. <span lang=ko-hang title="Hangul letter HIEUH"></span>),
or to smaller units such as
a base letterform (e.g. <span lang=ko-hang title="Hangul letter IEUNG"></span>)
and any combining marks that vary it (e.g. extra strokes that represent aspiration).
<p>In turn, a single encoding <a>character</a> can be represented in the data stream as one or more bytes;
and in programming environments one byte is sometimes also called a <a>character</a>.
<p>Therefore the term <a>character</a> is fairly ambiguous where technical precision is required.
<p>For text layout, we will refer to the <dfn export lt="typographic character unit|typographic character">typographic character unit</dfn>
as the basic unit of text.
Even within the realm of text layout,
the relevant <a>character</a> unit depends on the operation.
For example, line-breaking and letter-spacing will segment
a sequence of Thai characters that include U+0E33 THAI CHARACTER SARA AM differently;
or the behaviour of a conjunct consonant in a script such as Devanagari
may depend on the font in use.
So the <a>typographic character</a> represents a unit of the writing system&mdash;<!--
-->such as a Latin alphabetic letter (including its diacritics),
Hangul syllable,
Chinese ideographic character,
Myanmar syllable cluster&mdash;<!--
-->that is indivisible with respect to a particular typographic operation
(line-breaking, first-letter effects, tracking, justification, vertical arrangement, etc.).
<wpt>
word-break/word-break-break-all-007.html
word-break/word-break-break-all-008.html
</wpt>
<a href="http://www.unicode.org/reports/tr29/">Unicode Standard Annex #29: Text Segmentation</a>
defines a unit called the <dfn>grapheme cluster</dfn>
which approximates the <a>typographic character</a>.
A UA must use the <em>extended grapheme cluster</em>
(not <em>legacy grapheme cluster</em>), as defined in [[!UAX29]],
as the basis for its <a>typographic character unit</a>.
However, the UA should tailor the definitions
as required by typographic tradition
since the default rules are not always appropriate or ideal--
and is expected to tailor them differently
depending on the operation as needed.
<wpt>
line-breaking/line-breaking-013.html
line-breaking/line-breaking-014.html
</wpt>
<p class="note">
Note: The rules for such tailorings are out of scope for CSS.
<!--
however W3C currently maintains a wiki page
where some known tailorings are collected.
-->
<div class="example">
The following are some examples of <a>typographic character unit</a> tailorings
required by standard typesetting practice:
<ul>
<li>
<p>In some scripts such as Myanmar or Devanagari,
the <a>typographic character unit</a> for both justification and line-breaking
is an entire syllable,
which can include more than one [[!UAX29]] <a>grapheme cluster</a>.
<li>
<p>In other scripts such as Thai or Lao,
even though for line-breaking the <a>typographic character</a>
matches Unicode’s default <a>grapheme clusters</a>,
for letter-spacing the relevant unit
is <em>less</em> than a [[!UAX29]] <a>grapheme cluster</a>,
and may require decomposition or other substitutions
before spacing can be inserted.
<p>For instance,
to properly letter-space the Thai word คำ (U+0E04 + U+0E33),
the U+0E33 needs to be decomposed into U+0E4D + U+0E32,
and then the extra letter-space inserted before the U+0E32: คํ า.
<p>A slightly more complex example is น้ำ (U+0E19 + U+0E49 + U+0E33).
In this case, normal Thai shaping will first decompose the U+0E33 into U+0E4D + U+0E32
and then swap the U+0E4D with the U+0E49, giving U+0E19 + U+0E4D + U+0E49 + U+0E32.
As before the extra letter-space is then inserted before the U+0E32: นํ้ า.
<li>
<p>Vertical typesetting [[!CSS-WRITING-MODES-3]] can also require tailoring.
For example, when typesetting ''text-orientation/upright'' text,
Tibetan tsek and shad marks are kept with the preceding grapheme cluster,
rather than treated as an independent <a>typographic character unit</a>.
</ul>
</div>
<p>A <dfn export>typographic letter unit</dfn> or <dfn>letter</dfn> for the purpose of this specification
is a <a>typographic character unit</a> belonging to one of the Letter or Number general
categories in Unicode. [[!UAX44]]
See <a href="#character-properties">Character Properties</a>
for how to determine the Unicode properties of a <a>typographic character unit</a>.
<p>The rendering characteristics of a <a>typographic character unit</a> divided
by an element boundary is undefined.
Ideally each component should be rendered
according to the formatting requirements of its respective element’s properties
while maintaining correct shaping and positioning
of the <a>typographic character unit</a> as a whole.
However, depending on the nature of the formatting differences between its parts
and the capabilities of the font technology in use,
this is not always possible.
Therefore such a <a>typographic character unit</a>
may be rendered as belonging to either side of the boundary,
or as some approximation of belonging to both.
Authors are forewarned that dividing <a>grapheme clusters</a>
or ligatures
by element boundaries may give inconsistent or undesired results.
<h3 id="text-encoding">
Text Processing</h3>
CSS is built on [[UNICODE]].
UAs that support Unicode must adhere to all normative requirements
of the Unicode Core Standard,
except where explicitly overridden by CSS.
UAs that use a different encoding are not explicitly supported by the CSS specifications;
they are, however, expected to fulfill the same text handling requirements
by assuming an appropriate mapping between that encoding and Unicode.
<wpt>
text-encoding/shaping-join-001.html
text-encoding/shaping-join-002.html
text-encoding/shaping-join-003.html
text-encoding/shaping-no-join-001.html
text-encoding/shaping-no-join-002.html
text-encoding/shaping-no-join-003.html
text-encoding/shaping-tatweel-001.html
text-encoding/shaping-tatweel-002.html
text-encoding/shaping-tatweel-003.html
shaping/shaping-arabic-diacritics-001.html
shaping/shaping-arabic-diacritics-002.html
</wpt>
For the purpose of determining adjacency for text processing
(such as white space processing, text transformation, line-breaking, etc.),
and thus in general within this specification,
intervening [=inline box=] boundaries and [=out-of-flow=] elements
must be ignored.
With respect to text shaping, however, see [[#boundary-shaping]].
<wpt>
line-breaking/line-breaking-002.html
line-breaking/line-breaking-003.html
line-breaking/line-breaking-004.html
line-breaking/line-breaking-005.html
line-breaking/line-breaking-006.html
line-breaking/line-breaking-007.html
line-breaking/line-breaking-008.html
white-space/seg-break-transformation-018.html
white-space/seg-break-transformation-019.html
word-break/word-break-min-content-002.html
word-break/word-break-min-content-003.html
word-break/word-break-min-content-004.html
word-break/word-break-min-content-005.html
overflow-wrap/overflow-wrap-anywhere-010.html
</wpt>
<wpt pathprefix="css/CSS2/text"/>
white-space-processing-048.xht
white-space-processing-049.xht
</wpt>
<h2 id="transforming">
Transforming Text</h2>
<h3 id="text-transform-property" oldids="text-transform,caps-prop">
Case Transforms: the 'text-transform' property</h3>
<pre class="propdef">
Name: text-transform
Value: none | [capitalize | uppercase | lowercase ] || full-width || full-size-kana
Initial: none
Applies to: <a>inline boxes</a>
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
</pre>
<wpt>
inheritance.html
parsing/text-transform-valid.html
parsing/text-transform-invalid.html
parsing/text-transform-computed.html
text-transform/text-transform-multiple-001.html
</wpt>
<wpt pathprefix="/css/CSS2/css1">
c545-txttrans-000.xht
</wpt>
<wpt pathprefix="/css/CSS2/text/">
text-transform-005.xht
text-transform-applies-to-001.xht
text-transform-applies-to-002.xht
text-transform-applies-to-003.xht
text-transform-applies-to-005.xht
text-transform-applies-to-006.xht
text-transform-applies-to-007.xht
text-transform-applies-to-008.xht
text-transform-applies-to-009.xht
text-transform-applies-to-010.xht
text-transform-applies-to-011.xht
text-transform-applies-to-012.xht
text-transform-applies-to-013.xht
text-transform-applies-to-014.xht
text-transform-applies-to-015.xht
</wpt>
<p>This property transforms text for styling purposes.
It has no effect on the underlying content,
and must not affect the content of a plain text copy &amp; paste operation.
Note: The 'text-transform' property only affects the presentation layer;
correct casing for semantic purposes is expected to be represented
in the source document.
<wpt>
text-transform/text-transform-copy-paste-001-manual.html
</wpt>
<p>Values have the following meanings:
<dl dfn-for=text-transform dfn-type=value>
<dt><dfn>none</dfn></dt>
<dd>No effects.
<wpt>
text-transform/text-transform-none-001.xht
</wpt>
<wpt pathprefix="/css/CSS2/text/">
text-transform-004.xht
</wpt>
</dd>
<dt><dfn>capitalize</dfn></dt>
<dd>Puts the first <a>typographic letter unit</a> of each word, if lowercase, in titlecase;
other characters are unaffected.
<wpt>
text-transform/text-transform-capitalize-001.html
text-transform/text-transform-capitalize-003.html
text-transform/text-transform-capitalize-005.html
text-transform/text-transform-capitalize-007.html
text-transform/text-transform-capitalize-009.html
text-transform/text-transform-capitalize-010.html
text-transform/text-transform-capitalize-011.html
text-transform/text-transform-capitalize-014.html
text-transform/text-transform-capitalize-016.html
text-transform/text-transform-capitalize-018.html
text-transform/text-transform-capitalize-020.html
text-transform/text-transform-capitalize-022.html
text-transform/text-transform-capitalize-024.html
text-transform/text-transform-capitalize-026.html
text-transform/text-transform-capitalize-028.html
text-transform/text-transform-capitalize-030.html
text-transform/text-transform-capitalize-031.html
text-transform/text-transform-capitalize-032.xht
</wpt>
<wpt pathprefix="/css/CSS2/text/">
text-transform-001.xht
text-transform-cap-001.xht
text-transform-cap-002.xht
text-transform-cap-003.xht
</wpt>
</dd>
<dt><dfn>uppercase</dfn></dt>
<dd>Puts all <a>letters</a> in uppercase.
<wpt>
text-transform/text-transform-uppercase-101.xht
text-transform/text-transform-upperlower-001.html
text-transform/text-transform-upperlower-003.html
text-transform/text-transform-upperlower-005.html
text-transform/text-transform-upperlower-007.html
text-transform/text-transform-upperlower-009.html
text-transform/text-transform-upperlower-011.html
text-transform/text-transform-upperlower-015.html
text-transform/text-transform-upperlower-017.html
text-transform/text-transform-upperlower-019.html
text-transform/text-transform-upperlower-021.html
text-transform/text-transform-upperlower-023.html
text-transform/text-transform-upperlower-025.html
text-transform/text-transform-upperlower-027.html
text-transform/text-transform-upperlower-029.html
text-transform/text-transform-upperlower-031.html
text-transform/text-transform-upperlower-044.html
text-transform/text-transform-upperlower-101.html
text-transform/text-transform-upperlower-103.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
text-transform-003.xht
text-transform-bicameral-001.xht
text-transform-bicameral-003.xht
text-transform-bicameral-005.xht
text-transform-bicameral-007.xht
text-transform-bicameral-009.xht
text-transform-bicameral-011.xht
text-transform-bicameral-013.xht
text-transform-bicameral-015.xht
text-transform-bicameral-017.xht
text-transform-bicameral-019.xht
text-transform-bicameral-021.xht
text-transform-unicase-001.xht
text-transform-uppercase-001.xht
text-transform-uppercase-002.xht
</wpt>
<dt><dfn>lowercase</dfn></dt>
<dd>Puts all <a>letters</a> in lowercase.
<wpt>
text-transform/text-transform-lowercase-101.xht
text-transform/text-transform-lowercase-102.xht
text-transform/text-transform-upperlower-002.html
text-transform/text-transform-upperlower-004.html
text-transform/text-transform-upperlower-006.html
text-transform/text-transform-upperlower-008.html
text-transform/text-transform-upperlower-010.html
text-transform/text-transform-upperlower-012.html
text-transform/text-transform-upperlower-014.html
text-transform/text-transform-upperlower-016.html
text-transform/text-transform-upperlower-018.html
text-transform/text-transform-upperlower-020.html
text-transform/text-transform-upperlower-022.html
text-transform/text-transform-upperlower-024.html
text-transform/text-transform-upperlower-026.html
text-transform/text-transform-upperlower-028.html
text-transform/text-transform-upperlower-030.html
text-transform/text-transform-upperlower-102.html
text-transform/text-transform-upperlower-104.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
text-transform-002.xht
text-transform-bicameral-002.xht
text-transform-bicameral-004.xht
text-transform-bicameral-006.xht
text-transform-bicameral-008.xht
text-transform-bicameral-010.xht
text-transform-bicameral-012.xht
text-transform-bicameral-014.xht
text-transform-bicameral-016.xht
text-transform-bicameral-018.xht
text-transform-bicameral-020.xht
text-transform-bicameral-022.xht
text-transform-lowercase-001.xht
</wpt>
</dd>
<dt><dfn>full-width</dfn></dt>
<dd>Puts all <a>typographic character units</a> in fullwidth form.
If a character does not have a corresponding fullwidth form,
it is left as is.
This value is typically used to typeset Latin letters and digits
as if they were ideographic characters.
<wpt>
text-transform/text-transform-fullwidth-001.xht
text-transform/text-transform-fullwidth-002.xht
text-transform/text-transform-fullwidth-004.xht
text-transform/text-transform-fullwidth-005.xht
</wpt>
<dt><dfn>full-size-kana</dfn></dt>
<dd>Converts all [=small Kana=] characters to the equivalent [=full-size Kana=].
This value is typically used for ruby annotation text,
where authors may want all small Kana to be drawn as large Kana
to compensate for legibility issues at the small font sizes typically used in ruby.
<wpt>
text-transform/text-transform-full-size-kana-001.html
text-transform/text-transform-full-size-kana-002.html
text-transform/text-transform-full-size-kana-003.html
text-transform/text-transform-full-size-kana-004.html
text-transform/text-transform-full-size-kana-005.html
text-transform/text-transform-full-size-kana-006.html
text-transform/text-transform-full-size-kana-007.html
</wpt>
</dl>
<div class="example">
<p>The following example converts the ASCII characters
used in abbreviations in Japanese text to their fullwidth variants
so that they lay out and line break like ideographs:
<pre>abbr:lang(ja) { text-transform: full-width; }</pre>
</div>
Note: The purpose of 'text-transform' is
to allow for presentational casing transformations
without affecting the semantics of the document.
Note in particular that 'text-transform' casing operations are lossy,
and can distort the meaning of a text.
While accessiblity interfaces may wish to convey
the apparent casing of the rendered text to the user,
the transformed text cannot be relied on to accurately represent
the underlying meaning of the document.
<div class="example">
In this example,
the first line of text is capitalized as a visual effect.
<pre highlight=css>
section > p:first-of-type::first-line {
text-transform: uppercase;
}
</pre>
This effect cannot be written into the source document
because the position of the line break depends on layout.
But also, the capitalization is not reflecting a semantic distinction
and is not intended to affect the paragraph’s reading;
therefore it belongs in the presentation layer.
</div>
<div class="example">
In this example,
the [=ruby=] annotations,
which are half the size of the main paragraph text,
are transformed to use regular-size kana
in place of [=small kana=].
<pre highlight=css>
rt { font-size: 50%; text-transform: full-size-kana; }
:is(h1, h2, h3, h4) rt { text-transform: none; /* unset for large text*/ }
</pre>
Note that while this makes such letters easier to see at small type sizes,
the transformation distorts the text:
the reader needs to mentally substitute [=small kana=]
in the appropriate places--
not unlike reading a text in English
with all “s” characters substituted by “f”.
</div>
<h4 id="text-transform-mapping">
Mapping Rules</h4>
<p>For ''capitalize'', what constitutes a “word“ 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).
Out-of-flow elements and inline element boundaries
must not introduce a 'text-transform' word boundary
and must be ignored when determining such word boundaries.
<wpt>
text-transform/text-transform-capitalize-033.html
</wpt>
<p>
The UA must use the full case mappings for Unicode
characters, including any conditional casing rules, as defined in
Default Case Algorithm section of The Unicode Standard [[!UNICODE]].
If (and only if) the <a>content language</a>
of the element is, according to the rules of the
<a href="https://www.w3.org/TR/CSS2/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>.
<wpt>
writing-system/writing-system-text-transform-001.html
text-transform/text-transform-tailoring-001.html
text-transform/text-transform-tailoring-002.html
text-transform/text-transform-tailoring-002a.html
text-transform/text-transform-tailoring-003.html
text-transform/text-transform-tailoring-004.html
text-transform/text-transform-tailoring-005.html
text-transform/text-transform-upperlower-032.html
text-transform/text-transform-upperlower-033.html
text-transform/text-transform-upperlower-034.html
text-transform/text-transform-upperlower-035.html
text-transform/text-transform-upperlower-038.html
text-transform/text-transform-upperlower-039.html
text-transform/text-transform-upperlower-040.html
text-transform/text-transform-upperlower-041.html
text-transform/text-transform-upperlower-042.html
text-transform/text-transform-upperlower-043.html
</wpt>
<div class="example">
<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 <a>content language</a> is Turkish
written in its modern Latin-based <a>writing system</a>
(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>
<wpt pathprefix="/css/CSS2/text/">
text-transform-bicameral-005.xht
text-transform-bicameral-006.xht
</wpt>
<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 <code>&lt;wide&gt;</code> or the <code>&lt;narrow&gt;</code> tag
in their <code>Decomposition_Mapping</code> in [[!UAX44]].
For the <code>&lt;narrow&gt;</code> tag,
the mapping is from the code point to the decomposition (minus <code>&lt;narrow&gt;</code> tag),
and for the <code>&lt;wide&gt;</code> tag,
the mapping is from the decomposition (minus the <code>&lt;wide&gt;</code> tag)
back to the original code point.
<wpt>
text-transform/text-transform-fullwidth-001.xht
text-transform/text-transform-fullwidth-002.xht
text-transform/text-transform-fullwidth-004.xht
text-transform/text-transform-fullwidth-005.xht
text-transform/text-transform-fullwidth-006.html
text-transform/text-transform-fullwidth-007.html
</wpt>
<p>The mappings for small Kana to full-size Kana are defined in [[#small-kana]].
<h4 id="text-transform-order">
Order of Operations</h4>
<p>When multiple values are specified and therefore multiple transformations need to be applied,
they are applied in the following order:
<ol>
<li>''capitalize'', ''uppercase'', and ''lowercase''
<li>''full-width''
<li>''full-size-kana''
</ol>
<wpt>
text-transform/text-transform-multiple-001.html
</wpt>
<p>Text transformation happens after [[#white-space-phase-1]]
but before [[#white-space-phase-2]].
This means that ''full-width'' only transforms
U+0020 spaces to U+3000 within <a>preserved</a> [=white space=].
<wpt>
text-transform/text-transform-fullwidth-006.html
text-transform/text-transform-fullwidth-007.html
text-transform/text-transform-fullwidth-008.html
text-transform/text-transform-fullwidth-009.html
</wpt>
<p class="note">
Note: As defined in <a href="#order">Text Processing Order of Operations</a>,
transforming text affects line-breaking and other formatting operations.
<h2 id="white-space-property" oldids="white-space-collapsing,text-wrap">
White Space and Wrapping: the 'white-space' property</h2>
<pre class="propdef">
Name: white-space
Value: normal | pre | nowrap | pre-wrap | break-spaces | pre-line
Initial: normal
Applies to: <a>inline boxes</a>
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
</pre>
<wpt>
inheritance.html
parsing/white-space-valid.html
parsing/white-space-invalid.html
parsing/white-space-computed.html
white-space/append-whitespace-only-node-crash-001.html
white-space/ws-break-spaces-applies-to-001.html
white-space/ws-break-spaces-applies-to-002.html
white-space/ws-break-spaces-applies-to-003.html
white-space/ws-break-spaces-applies-to-005.html
white-space/ws-break-spaces-applies-to-006.html
white-space/ws-break-spaces-applies-to-007.html
white-space/ws-break-spaces-applies-to-008.html
white-space/ws-break-spaces-applies-to-009.html
white-space/ws-break-spaces-applies-to-010.html
white-space/ws-break-spaces-applies-to-011.html
white-space/ws-break-spaces-applies-to-012.html
white-space/ws-break-spaces-applies-to-013.html
white-space/ws-break-spaces-applies-to-014.html
white-space/ws-break-spaces-applies-to-015.html
white-space/white-space-pre-031.html
white-space/white-space-pre-032.html
white-space/white-space-pre-034.html
white-space/white-space-pre-035.html
</wpt>
<wpt pathprefix="/css/CSS2/css1/">
c562-white-sp-000.xht
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-006.xht
white-space-007.xht
white-space-applies-to-001.xht
white-space-applies-to-002.xht
white-space-applies-to-002.xht
white-space-applies-to-003.xht
white-space-applies-to-005.xht
white-space-applies-to-006.xht
white-space-applies-to-007.xht
white-space-applies-to-008.xht
white-space-applies-to-009.xht
white-space-applies-to-010.xht
white-space-applies-to-011.xht
white-space-applies-to-012.xht
white-space-applies-to-013.xht
white-space-applies-to-014.xht
white-space-applies-to-015.xht
white-space-mixed-001.xht
white-space-mixed-002.xht
white-space-mixed-003.xht
<!-- manual test
white-space-mixed-004.xht
-->
</wpt>
<p>This property specifies two things:
<ul>
<li>whether and how <a>white space</a> inside the element is collapsed
<li>whether lines may <a>wrap</a> at unforced <a>soft wrap opportunities</a>
</ul>
<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 dfn-for=white-space dfn-type=value>
<dt><dfn>normal</dfn></dt>
<dd>This value directs user agents to collapse sequences of <a>white space</a>
into a single character (or <a href="#line-break-transform">in some
cases</a>, no character).
Lines may wrap at allowed <a>soft wrap opportunities</a>,
as determined by the line-breaking rules in effect,
in order to minimize inline-axis overflow.
<wpt>
white-space/white-space-normal-011.html
white-space/white-space-pre-031.html
white-space/white-space-wrap-after-nowrap-001.html
line-break/line-break-anywhere-and-white-space-004.html
line-break/line-break-anywhere-and-white-space-005.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-normal-001.xht
white-space-normal-002.xht
white-space-normal-003.xht
white-space-normal-004.xht
white-space-normal-005.xht
white-space-normal-006.xht
white-space-normal-007.xht
white-space-normal-008.xht
white-space-normal-009.xht
white-space-p-element-001.xht
</wpt>
<dt><dfn>pre</dfn></dt>
<dd>This value prevents user agents from collapsing sequences of <a>white space</a>.
<a>Segment breaks</a> such as line feeds
are preserved as <a>forced line breaks</a>.
Lines only break at <a>forced line breaks</a>;
content that does not fit within the block container overflows it.
<wpt pathprefix="/css/CSS2/text/">
white-space-pre-001.xht
white-space-pre-002.xht
white-space-pre-005.xht
white-space-pre-006.xht
<!--manual test
white-space-pre-007.xht
-->
white-space-pre-element-001.xht
</wpt>
<wpt>
white-space/white-space-pre-031.html
white-space/white-space-pre-032.html
white-space/white-space-pre-034.html
white-space/white-space-pre-035.html
white-space/white-space-pre-011.html
white-space/white-space-pre-051.html
white-space/white-space-pre-052.html
line-break/line-break-anywhere-and-white-space-001.html
line-break/line-break-anywhere-and-white-space-003.html
white-space/white-space-zero-fontsize-001.html
white-space/white-space-zero-fontsize-002.html
white-space/white-space-intrinsic-size-015.html
white-space/white-space-intrinsic-size-016.html
white-space/white-space-intrinsic-size-018.html
</wpt>
<dt><dfn>nowrap</dfn>
<dd>Like ''white-space/normal'', this value collapses <a>white space</a>;
but like ''pre'', it does not allow wrapping.
<wpt>
white-space/white-space-nowrap-011.html
white-space/white-space-wrap-after-nowrap-001.html
line-break/line-break-anywhere-and-white-space-002.html
overflow-wrap/overflow-wrap-anywhere-008.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-nowrap-001.xht
white-space-nowrap-005.xht
white-space-nowrap-006.xht
text-align-white-space-004.xht
text-align-white-space-008.xht
white-space-nowrap-attribute-001.xht
white-space-processing-006.xht
</wpt>
<dt><dfn>pre-wrap</dfn></dt>
<dd>Like ''pre'', this value preserves <a>white space</a>;
but like ''white-space/normal'', it allows wrapping.
<wpt>
white-space/pre-wrap-001.html
white-space/pre-wrap-002.html
white-space/pre-wrap-003.html
white-space/pre-wrap-004.html
white-space/pre-wrap-005.html
white-space/pre-wrap-006.html
white-space/pre-wrap-007.html
white-space/pre-wrap-009.html
white-space/pre-wrap-010.html
white-space/pre-wrap-011.html
white-space/pre-wrap-012.html
white-space/pre-wrap-013.html
white-space/pre-wrap-014.html
white-space/pre-wrap-051.html
white-space/pre-wrap-052.html
white-space/textarea-pre-wrap-001.html
white-space/textarea-pre-wrap-002.html
white-space/textarea-pre-wrap-003.html
white-space/textarea-pre-wrap-004.html
white-space/textarea-pre-wrap-005.html
white-space/textarea-pre-wrap-006.html
white-space/textarea-pre-wrap-007.html
white-space/textarea-pre-wrap-011.html
white-space/textarea-pre-wrap-012.html
white-space/textarea-pre-wrap-013.html
white-space/textarea-pre-wrap-014.html
white-space/white-space-pre-032.html
white-space/pre-wrap-leading-spaces-001.html
white-space/pre-wrap-leading-spaces-002.html
white-space/pre-wrap-leading-spaces-003.html
white-space/pre-wrap-leading-spaces-004.html
white-space/pre-wrap-leading-spaces-005.html
white-space/pre-wrap-leading-spaces-006.html
white-space/pre-wrap-leading-spaces-007.html
white-space/pre-wrap-leading-spaces-008.html
white-space/pre-wrap-leading-spaces-009.html
white-space/pre-wrap-leading-spaces-010.html
white-space/pre-wrap-leading-spaces-011.html
white-space/pre-wrap-leading-spaces-012.html
white-space/pre-wrap-leading-spaces-013.html
white-space/pre-wrap-leading-spaces-014.html
white-space/white-space-pre-wrap-trailing-spaces-001.html
white-space/white-space-pre-wrap-trailing-spaces-002.html
white-space/white-space-pre-wrap-trailing-spaces-003.html
white-space/white-space-pre-wrap-trailing-spaces-004.html
white-space/white-space-pre-wrap-trailing-spaces-005.html
white-space/white-space-pre-wrap-trailing-spaces-006.html
white-space/white-space-pre-wrap-trailing-spaces-007.html
white-space/white-space-pre-wrap-trailing-spaces-008.html
white-space/white-space-pre-wrap-trailing-spaces-010.html
white-space/white-space-pre-wrap-trailing-spaces-011.html
white-space/trailing-other-space-separators-002.html
white-space/pre-wrap-tab-001.html
white-space/pre-wrap-tab-002.html
white-space/pre-wrap-tab-003.html
white-space/pre-wrap-tab-004.html
white-space/pre-wrap-tab-005.html
white-space/pre-wrap-tab-006.html
line-break/line-break-anywhere-and-white-space-006.html
line-break/line-break-anywhere-and-white-space-007.html
white-space/white-space-intrinsic-size-013.html
white-space/white-space-intrinsic-size-014.html
white-space/white-space-intrinsic-size-017.html
</wpt>
<dt><dfn>break-spaces</dfn></dt>
<dd>The behavior is identical to that of ''white-space/pre-wrap'',
except that:
* Any sequence of <a>preserved</a> [=white space=]
or [=other space separators=]
always takes up space,
including at the end of the line.
* A line breaking opportunity exists after every <a>preserved</a> <a>white space</a> character
and after every [=other space separator=]
(including between adjacent spaces).
<wpt>
overflow-wrap/overflow-wrap-break-word-002.html
overflow-wrap/overflow-wrap-anywhere-002.html
white-space/break-spaces-001.html
white-space/break-spaces-002.html
white-space/break-spaces-003.html
white-space/break-spaces-004.html
white-space/break-spaces-005.html
white-space/break-spaces-006.html
white-space/break-spaces-007.html
white-space/break-spaces-008.html
white-space/break-spaces-009.html
white-space/break-spaces-010.html
white-space/break-spaces-051.html
white-space/break-spaces-052.html
white-space/white-space-pre-034.html
white-space/textarea-break-spaces-001.html
white-space/textarea-break-spaces-002.html
white-space/break-spaces-before-first-char-001.html
white-space/break-spaces-before-first-char-002.html
white-space/break-spaces-before-first-char-003.html
white-space/break-spaces-before-first-char-004.html
white-space/break-spaces-before-first-char-005.html
white-space/break-spaces-before-first-char-006.html
white-space/break-spaces-before-first-char-007.html
white-space/break-spaces-before-first-char-008.html
white-space/break-spaces-before-first-char-009.html
white-space/break-spaces-before-first-char-010.html
white-space/break-spaces-before-first-char-011.html
white-space/break-spaces-before-first-char-012.html
white-space/break-spaces-before-first-char-013.html
white-space/break-spaces-before-first-char-014.html
white-space/break-spaces-before-first-char-015.html
white-space/break-spaces-before-first-char-016.html
white-space/break-spaces-before-first-char-017.html
white-space/break-spaces-before-first-char-018.html
white-space/tab-stop-threshold-005.html
white-space/tab-stop-threshold-006.html
word-break/word-break-break-all-017.html
white-space/break-spaces-tab-001.html
white-space/break-spaces-tab-002.html
white-space/break-spaces-tab-003.html
white-space/break-spaces-tab-004.html
white-space/break-spaces-tab-005.html
white-space/break-spaces-tab-006.html
white-space/break-spaces-with-overflow-wrap-001.html
white-space/break-spaces-with-overflow-wrap-002.html
white-space/break-spaces-with-overflow-wrap-003.html
white-space/break-spaces-with-overflow-wrap-004.html
white-space/break-spaces-with-overflow-wrap-005.html
white-space/break-spaces-with-overflow-wrap-006.html
white-space/break-spaces-with-overflow-wrap-007.html
white-space/break-spaces-with-overflow-wrap-008.html
white-space/break-spaces-with-overflow-wrap-009.html
white-space/break-spaces-with-overflow-wrap-010.html
line-break/line-break-anywhere-and-white-space-008.html
line-break/line-break-anywhere-and-white-space-009.html
white-space/ws-break-spaces-applies-to-001.html
white-space/ws-break-spaces-applies-to-002.html
white-space/ws-break-spaces-applies-to-003.html
white-space/ws-break-spaces-applies-to-005.html
white-space/ws-break-spaces-applies-to-006.html
white-space/ws-break-spaces-applies-to-007.html
white-space/ws-break-spaces-applies-to-008.html
white-space/ws-break-spaces-applies-to-009.html
white-space/ws-break-spaces-applies-to-010.html
white-space/ws-break-spaces-applies-to-011.html
white-space/ws-break-spaces-applies-to-012.html
white-space/ws-break-spaces-applies-to-013.html
white-space/ws-break-spaces-applies-to-014.html
white-space/ws-break-spaces-applies-to-015.html
white-space/break-spaces-newline-011.html
white-space/break-spaces-newline-012.html
white-space/break-spaces-newline-013.html
white-space/break-spaces-newline-014.html
white-space/break-spaces-newline-015.html
white-space/break-spaces-newline-016.html
</wpt>
Such [=preserved=] [=white space characters=]
and [=other space separators=]
take up space and do not [=hang=],
and thus affect the box's intrinsic sizes
([=min-content size=] and [=max-content size=]).
<wpt>
white-space/white-space-intrinsic-size-001.html
white-space/white-space-intrinsic-size-002.html
</wpt>
<p class="note">Note: This value does not guarantee that there will never be any overflow due to white space:
for example, if the line length is so short that even a single white space character does not fit,
overflow is unavoidable.</p>
<dt><dfn>pre-line</dfn></dt>
<dd>Like ''white-space/normal'', this value collapses consecutive [=white space characters=] and allows wrapping,
but preserves <a>segment breaks</a> in the source as <a>forced line breaks</a>.
<wpt pathprefix="/css/CSS2/text/">
white-space-005.xht
white-space-generated-content-before-001.xht
white-space-processing-004.xht
white-space-processing-007.xht
white-space-processing-010.xht
white-space-processing-017.xht
white-space-processing-021.xht
white-space-processing-024.xht
white-space-processing-027.xht
white-space-processing-028.xht
white-space-processing-029.xht
white-space-processing-030.xht
white-space-processing-035.xht
white-space-processing-036.xht
white-space-processing-045.xht
white-space-processing-053.xht
text-align-white-space-002.xht
text-align-white-space-006.xht
</wpt>
<wpt>
white-space/pre-line-051.html
white-space/pre-line-052.html
white-space/white-space-pre-035.html
white-space/white-space-intrinsic-size-019.html
white-space/white-space-intrinsic-size-020.html
</wpt>
</dl>
<p>[=White space=] that was not removed or collapsed due to white space processing
is called <dfn export local-lt="preserved">preserved white space</dfn>.
Note: In some cases,
[=preserved white space=] and [=other space separators=]
can <a>hang</a> when at the end of the line;
this can affect whether they are measured for [=intrinsic sizing=].
<p>The following informative table summarizes the behavior of various
'white-space' values:</p>
<table class="data">
<colgroup class="header"></colgroup>
<colgroup span=5></colgroup>
<thead>
<tr>
<th></th>
<th>New Lines</th>
<th>Spaces and Tabs</th>
<th>Text Wrapping</th>
<th>End-of-line [=spaces=]</th>
<th>End-of-line [=other space separators=]</th>
</tr>
</thead>
<tbody>
<tr>
<th>''white-space/normal''</th>
<td>Collapse</td>
<td>Collapse</td>
<td>Wrap</td>
<td>Remove</td>
<td>Hang</td>
</tr>
<tr>
<th>''pre''</th>
<td>Preserve</td>
<td>Preserve</td>
<td>No wrap</td>
<td>Preserve</td>
<td>No wrap</td>
</tr>
<tr>
<th>''nowrap''</th>
<td>Collapse</td>
<td>Collapse</td>
<td>No wrap</td>
<td>Remove</td>
<td>Hang</td>
</tr>
<tr>
<th>''pre-wrap''</th>
<td>Preserve</td>
<td>Preserve</td>
<td>Wrap</td>
<td>Hang</td>
<td>Hang</td>
</tr>
<tr>
<th>''break-spaces''</th>
<td>Preserve</td>
<td>Preserve</td>
<td>Wrap</td>
<td>Wrap</td>
<td>Wrap</td>
</tr>
<tr>
<th>''pre-line''</th>
<td>Preserve</td>
<td>Collapse</td>
<td>Wrap</td>
<td>Remove</td>
<td>Hang</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 (''white-space/normal'' and ''nowrap'') is presented below:
<ul>
<li>A sequence of segment breaks and other <a>white space</a> 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 <a>white space</a>
to collapse into a zero width space.
<li>Otherwise, consecutive <a>white space</a> 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 can be
separated by a particular newline sequence (such as a line feed or
CRLF pair), or delimited by some other mechanism, such as the SGML
<code>RECORD-START</code> and <code>RECORD-END</code> tokens.
For CSS processing, each document language&ndash;defined segment break
and each line feed (U+000A)
in the text is treated as a <dfn export>segment break</dfn>,
which is then interpreted for rendering as specified by the 'white-space' property.
<wpt pathprefix="/css/CSS2/text">
white-space-processing-005.xht
white-space-processing-006.xht
white-space-processing-007.xht
</wpt>
<p class="note">Note: A document parser might
not only normalize any <a>segment breaks</a>,
but also collapse other space characters or
otherwise process 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: Anonymous blocks consisting entirely of
<a>collapsible</a> <a>white space</a> are removed from the rendering tree.
Thus any such <a>white space</a> surrounding a block-level element is collapsed away.
See [[CSS2]] section
<a href="https://www.w3.org/TR/CSS2/visuren.html#anonymous">9.2.2.1</a></p>
<p>
Control characters (<a>Unicode category</a> <code>Cc</code>)--
other than tabs (U+0009),
line feeds (U+000A),
carriage returns (U+000D)
and sequences that form a <a>segment break</a>--
must be rendered as a visible glyph
which the UA must synthethize if the glyphs found in the font are not visible,
and must be otherwise treated as any other character
of the Other Symbols (<code>So</code>) <a>general category</a> and Common <a lt="Unicode script">script</a>.
The UA may use a glyph provided by a font specifically for the control character,
substitute the glyphs provided for the corresponding symbol in the Control Pictures block,
generate a visual representation of its code point value,
or use some other method to provide an appropriate visible glyph.
As required by [[!UNICODE]],
unsupported <code>Default_ignorable</code> characters
must be ignored for text rendering.
<wpt>
white-space/control-chars-000.html
white-space/control-chars-001.html
white-space/control-chars-002.html
white-space/control-chars-003.html
white-space/control-chars-004.html
white-space/control-chars-005.html
white-space/control-chars-006.html
white-space/control-chars-007.html
white-space/control-chars-008.html
white-space/control-chars-00B.html
white-space/control-chars-00C.html
white-space/control-chars-00D.html
white-space/control-chars-00E.html
white-space/control-chars-00F.html
white-space/control-chars-010.html
white-space/control-chars-011.html
white-space/control-chars-012.html
white-space/control-chars-013.html
white-space/control-chars-014.html
white-space/control-chars-015.html
white-space/control-chars-016.html
white-space/control-chars-017.html
white-space/control-chars-018.html
white-space/control-chars-019.html
white-space/control-chars-01A.html
white-space/control-chars-01B.html
white-space/control-chars-01C.html
white-space/control-chars-01D.html
white-space/control-chars-01E.html
white-space/control-chars-01F.html
white-space/control-chars-07F.html
white-space/control-chars-080.html
white-space/control-chars-081.html
white-space/control-chars-082.html
white-space/control-chars-083.html
white-space/control-chars-084.html
white-space/control-chars-085.html
white-space/control-chars-086.html
white-space/control-chars-087.html
white-space/control-chars-088.html
white-space/control-chars-089.html
white-space/control-chars-08A.html
white-space/control-chars-08B.html
white-space/control-chars-08C.html
white-space/control-chars-08D.html
white-space/control-chars-08E.html
white-space/control-chars-08F.html
white-space/control-chars-090.html
white-space/control-chars-091.html
white-space/control-chars-092.html
white-space/control-chars-093.html
white-space/control-chars-094.html
white-space/control-chars-095.html
white-space/control-chars-096.html
white-space/control-chars-097.html
white-space/control-chars-098.html
white-space/control-chars-099.html
white-space/control-chars-09A.html
white-space/control-chars-09B.html
white-space/control-chars-09C.html
white-space/control-chars-09D.html
white-space/control-chars-09E.html
white-space/control-chars-09F.html
</wpt>
<wpt pathprefix="/css/CSS2/other-formats">
<!--manual
control-characters-001.html
-->
</wpt>
<wpt pathprefix="/css/CSS2/text">
<!--manual
control-characters-002.html
white-space-control-characters-001.xht
-->
</wpt>
Carriage returns (U+000D) are treated identically to spaces (U+0020) in all respects.
<wpt>
white-space/control-chars-00D.html
</wpt>
<wpt pathprefix="/css/CSS2/text">
white-space-processing-005.xht
white-space-processing-006.xht
white-space-processing-007.xht
</wpt>
Note: For HTML documents,
carriage returns present in the source code
are converted to line feeds at the parsing stage
(see [[HTML#preprocessing-the-input-stream]]
and the definition of [=normalize newlines=] in [[INFRA]])
and therefore do no appear as U+000D to CSS.
However, the character <em>is</em> preserved--
and the above rule observable--
when encoded using an escape sequence (<code class=lang-html>&amp;#x0d;</code>).
<h3 id="white-space-rules">
The White Space Processing Rules</h3>
<p>Except where specified otherwise,
white space processing in CSS affects only
the <dfn export lt="white space|white space characters| document white space|document white space characters">document white space characters</dfn>:
<dfn>spaces</dfn> (U+0020), <dfn>tabs</dfn> (U+0009), and <a href="#white-space-processing">segment breaks</a>.
<wpt pathprefix="/css/CSS2/text/">
white-space-normal-003.xht
white-space-normal-004.xht
white-space-normal-005.xht
white-space-normal-006.xht
white-space-normal-007.xht
white-space-normal-008.xht
white-space-nowrap-005.xht
white-space-nowrap-006.xht
white-space-pre-005.xht
white-space-pre-006.xht
white-space-processing-054.xht
white-space-processing-055.xht
white-space-processing-056.xht
</wpt>
<p class="note">
Note: The set of characters considered <a>document white space</a> (part of the document content)
and those considered syntactic white space (part of the CSS syntax)
are not necessarily identical.
However, since both include spaces (U+0020), tabs (U+0009), and line feeds (U+000A)
most authors won't notice any differences.
<p>Besides
Space (U+0020)
and No-Break Space (U+00A0),
Unicode [[UNICODE]] defines a number of additional space separator characters.
In this specification
all characters in the Unicode Zs category (See [[!UAX44]])
except Space (U+0020)
and No-Break Space (U+00A0)
are collectively referred to as
<dfn>other space separators</dfn>.
<wpt>
white-space/trailing-other-space-separators-001.html
white-space/trailing-other-space-separators-002.html
white-space/trailing-other-space-separators-003.html
white-space/trailing-other-space-separators-004.html
white-space/trailing-other-space-separators-break-spaces-001.html
white-space/trailing-other-space-separators-break-spaces-002.html
white-space/trailing-other-space-separators-break-spaces-003.html
white-space/trailing-other-space-separators-break-spaces-004.html
white-space/trailing-other-space-separators-break-spaces-005.html
white-space/trailing-other-space-separators-break-spaces-006.html
white-space/trailing-other-space-separators-break-spaces-007.html
white-space/trailing-other-space-separators-break-spaces-008.html
white-space/trailing-other-space-separators-break-spaces-009.html
white-space/trailing-other-space-separators-break-spaces-010.html
white-space/trailing-other-space-separators-break-spaces-011.html
white-space/trailing-other-space-separators-break-spaces-012.html
white-space/trailing-other-space-separators-break-spaces-013.html
white-space/trailing-other-space-separators-break-spaces-014.html
white-space/trailing-other-space-separators-break-spaces-015.html
</wpt>
<h4 id="white-space-phase-1">Phase I: Collapsing and Transformation</h4>
<p>For each inline (including anonymous inlines;
see [[CSS2]] section <a href="https://www.w3.org/TR/CSS2/visuren.html#anonymous">9.2.2.1</a>)
within an [=inline formatting context=],
[=white space characters=] are processed as follows
prior to [=line breaking=] and <a href="https://www.w3.org/TR/css-writing-modes-3/#text-direction">bidi reordering</a>,
ignoring <dfn noexport>bidi formatting characters</dfn>
(characters with the <code>Bidi_Control</code> property [[!UAX9]])
as if they were not there:
<wpt>
white-space/white-space-collapse-002.html
white-space/white-space-normal-011.html
white-space/white-space-nowrap-011.html
</wpt>
<ul>
<li id="collapse"><p>If 'white-space' is set to
''white-space/normal'', ''nowrap'', or ''pre-line'',
[=white space characters=] are considered <dfn export lt="collapsible white space" local-lt="collapsible">collapsible</dfn>
and are processed by performing the following steps:</p>
<ol>
<li>Any sequence of collapsible [=spaces=] and [=tabs=]
immediately preceding or following a <a>segment break</a>
is removed.
<wpt>
white-space/seg-break-transformation-000.html
white-space/white-space-normal-011.html
white-space/white-space-nowrap-011.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-processing-002.xht
white-space-processing-003.xht
white-space-processing-004.xht
white-space-processing-008.xht
white-space-processing-009.xht
white-space-processing-010.xht
white-space-processing-005.xht
white-space-processing-006.xht
white-space-processing-007.xht
</wpt>
</li>
<li>Collapsible <a>segment breaks</a> are transformed for
rendering according to the <a href="#line-break-transform">segment break transformation rules</a>.
</li>
<li>Every [=collapsible=] [=tab=] is converted to a collapsible space (U+0020).
<wpt>
white-space/white-space-collapse-000.html
white-space/white-space-normal-011.html
white-space/white-space-nowrap-011.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-processing-019.xht
white-space-processing-020.xht
white-space-processing-021.xht
</wpt>
</li>
<li>Any [=collapsible=] [=space=] immediately following another [=collapsible=] [=space=]&mdash;even
one outside the boundary of the inline containing that [=space=],
provided both [=spaces=] are within the same inline formatting
context&mdash;is collapsed to have zero advance width. (It is
invisible, but retains its <a>soft wrap opportunity</a>, if any.)
<wpt>
white-space/white-space-collapse-001.html
white-space/white-space-empty-text-sibling.html
white-space/white-space-normal-011.html
white-space/white-space-nowrap-011.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-001.xht
white-space-003.xht
white-space-005.xht
white-space-collapsing-001.xht
white-space-collapsing-002.xht
white-space-collapsing-004.xht
white-space-collapsing-005.xht
white-space-collapsing-breaks-001.xht
white-space-mixed-001.xht
white-space-mixed-002.xht
white-space-normal-001.xht
white-space-processing-001.xht
white-space-processing-022.xht
white-space-processing-023.xht
white-space-processing-024.xht
white-space-processing-025.xht
white-space-processing-026.xht
white-space-processing-027.xht
white-space-processing-028.xht
white-space-processing-029.xht
white-space-processing-030.xht
white-space-processing-031.xht
white-space-processing-032.xht
white-space-processing-033.xht
white-space-processing-034.xht
white-space-processing-035.xht
white-space-processing-036.xht
white-space-processing-050.xht
white-space-processing-051.xht
white-space-processing-053.xht
</wpt>
</li>
</ol>
</li>
<li><p>If 'white-space' is set to ''pre'', ''pre-wrap'', or ''break-spaces'',
any sequence of spaces is treated as a sequence of non-breaking spaces.
However, for ''pre-wrap'',
a <a>soft wrap opportunity</a> exists at the end of a sequence of [=spaces=] and/or [=tabs=],
while for ''break-spaces'',
a <a>soft wrap opportunity</a> exists after every [=space=] and every [=tab=].
<wpt>
white-space/white-space-pre-011.html
overflow-wrap/overflow-wrap-break-word-004.html
overflow-wrap/overflow-wrap-break-word-005.html
overflow-wrap/overflow-wrap-break-word-006.html
overflow-wrap/overflow-wrap-break-word-007.html
overflow-wrap/overflow-wrap-anywhere-004.html
overflow-wrap/overflow-wrap-anywhere-005.html
word-break/word-break-break-all-011.html
word-break/word-break-break-all-012.html
word-break/word-break-break-all-013.html
word-break/word-break-break-all-015.html
white-space/break-spaces-006.html
white-space/break-spaces-007.html
white-space/break-spaces-008.html
white-space/break-spaces-009.html
white-space/break-spaces-010.html
white-space/break-spaces-before-first-char-001.html
white-space/break-spaces-before-first-char-002.html
white-space/break-spaces-before-first-char-003.html
white-space/break-spaces-before-first-char-004.html
white-space/break-spaces-before-first-char-005.html
white-space/break-spaces-before-first-char-006.html
white-space/break-spaces-before-first-char-011.html
white-space/pre-wrap-008.html
white-space/pre-wrap-015.html
white-space/pre-wrap-016.html
white-space/pre-wrap-leading-spaces-001.html
white-space/pre-wrap-leading-spaces-002.html
white-space/pre-wrap-leading-spaces-003.html
white-space/pre-wrap-leading-spaces-004.html
white-space/pre-wrap-leading-spaces-005.html
white-space/pre-wrap-leading-spaces-006.html
white-space/pre-wrap-leading-spaces-007.html
white-space/pre-wrap-leading-spaces-008.html
white-space/pre-wrap-leading-spaces-009.html
white-space/pre-wrap-leading-spaces-010.html
white-space/pre-wrap-leading-spaces-011.html
white-space/pre-wrap-leading-spaces-012.html
white-space/pre-wrap-leading-spaces-013.html
white-space/pre-wrap-leading-spaces-014.html
white-space/break-spaces-tab-001.html
white-space/break-spaces-tab-002.html
white-space/break-spaces-tab-003.html
white-space/break-spaces-tab-004.html
white-space/pre-wrap-tab-001.html
white-space/pre-wrap-tab-002.html
white-space/pre-wrap-tab-003.html
white-space/pre-wrap-tab-004.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-002.xht
white-space-004.xht
white-space-processing-011.xht
white-space-processing-012.xht
white-space-processing-013.xht
white-space-processing-052.xht
</wpt>
</ul>
<wpt pathprefix="/css/CSS2/">
bidi-text/bidi-002.xht
bidi-text/bidi-004.xht
bidi-text/line-breaking-bidi-001.xht
bidi-text/line-breaking-bidi-002.xht
bidi-text/line-breaking-bidi-003.xht
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-collapsing-bidi-001.xht
white-space-collapsing-bidi-002.xht
</wpt>
<div class="example" id="egbidiwscollapse">
<p>The following example illustrates
the interaction of white-space collapsing and bidirectionality.
Consider the following markup fragment, taking special note of [=spaces=]
(with varied backgrounds and borders for emphasis and identification):
<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 'white-space' property is set to ''white-space/normal'',
the white-space processing model will result in the following:
<ul style="line-height:1.3">
<li>The [=space=] before the B (<span class="egbidiwsbB">&#160;</span>)
will collapse with the [=space=] after the A (<span class="egbidiwsaA">&#160;</span>).
<li>The [=space=] before the C (<span class="egbidiwsbC">&#160;</span>)
will collapse with the [=space=] after the B (<span class="egbidiwsaB">&#160;</span>).
</ul>
<p>This will 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.
The text will then be ordered according to the Unicode bidirectional algorithm,
with the end result being:
<pre>A<span class="egbidiwsaA">&#160;</span><span class="egbidiwsaB">&#160;</span>BC</pre>
<p>Note that there will be 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.
</div>
<wpt pathprefix="/css/CSS2/text/">
white-space-bidirectionality-001.xht
</wpt>
<h4 id="white-space-phase-2">Phase II: Trimming and Positioning</h4>
<p>Then, the entire block is rendered.
Inlines are laid out,
taking <a href="https://www.w3.org/TR/css-writing-modes-3/#text-direction">bidi reordering</a> into account,
and <a>wrapping</a> as specified by the 'white-space' property.
As each line is laid out,
<ol>
<li>A sequence of [=collapsible=] [=spaces=] at the beginning of a line
is removed.
<wpt>
white-space/line-edge-white-space-collapse-002.html
white-space/break-spaces-051.html
white-space/break-spaces-052.html
white-space/pre-line-051.html
white-space/pre-line-052.html
white-space/pre-wrap-051.html
white-space/pre-wrap-052.html
white-space/white-space-pre-051.html
white-space/white-space-pre-052.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-collapsing-003.xht
white-space-collapsing-bidi-003.xht
white-space-normal-001.xht
white-space-normal-002.xht
white-space-processing-037.xht
white-space-processing-038.xht
white-space-processing-039.xht
white-space-processing-040.xht
white-space-processing-041.xht
</wpt>
<li>If the [=tab size=] is zero, [=preserved=] [=tabs=] are not rendered.
Otherwise, each [=preserved=] [=tab=] is rendered as a horizontal shift
that lines up the start edge of the next glyph with the next <a>tab stop</a>.
If this distance is less than 0.5<a href="https://www.w3.org/TR/css-values-3/#ch">ch</a>,
then the subsequent <a>tab stop</a> is used instead.
<dfn lt="tab stop">Tab stops</dfn> occur at points that are multiples of the [=tab size=]
from the starting content edge
of the [=preserved=] [=tab=]'s nearest [=block container=] ancestor.
The [=tab size=] is given by the 'tab-size' property.
<wpt>
white-space/tab-stop-threshold-001.html
white-space/tab-stop-threshold-002.html
white-space/tab-stop-threshold-003.html
white-space/tab-stop-threshold-004.html
white-space/tab-stop-threshold-005.html
white-space/tab-stop-threshold-006.html
white-space/white-space-pre-011.html
tab-size/tab-min-rendered-width-1.html
tab-size/tab-size-integer-003.html
text-indent/text-indent-tab-positions-001.html
tab-size/tab-size-inline-002.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-processing-042.xht
</wpt>
Note: See [[UAX9]] for <a href="http://unicode.org/reports/tr9/#L1">rules on how U+0009 tabulation interacts with bidi</a>.
<li>A sequence at the end of a line
of <a>collapsible</a> [=spaces=]
is removed,
as well as any trailing U+1680 OGHAM SPACE MARK
whose 'white-space' property is ''white-space/normal'', ''nowrap'', or ''pre-line''.
<wpt>
white-space/line-edge-white-space-collapse-001.html
white-space/pre-float-001.html
white-space/pre-wrap-float-001.html
white-space/trailing-space-before-br-001.html
white-space/trailing-ogham-001.html
white-space/trailing-ogham-002.html
white-space/trailing-ogham-003.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-collapsing-003.xht
white-space-collapsing-bidi-003.xht
white-space-normal-001.xht
white-space-normal-002.xht
white-space-processing-005.xht
white-space-processing-043.xht
white-space-processing-044.xht
white-space-processing-045.xht
white-space-processing-046.xht
white-space-processing-047.xht
</wpt>
In the case of bidirectional text,
any sequence of [=collapsible=] [=spaces=] located at the end of the line
prior to <a href="https://www.w3.org/TR/css-writing-modes/#text-direction">bidi reordering</a> [[CSS-WRITING-MODES-3]]
is also removed,
and bidi reordering is applied on the remaining content of the line.
<wpt>
white-space/eol-spaces-bidi-001.html
white-space/trailing-space-rtl-001.html
</wpt>
<li>If there remains any sequence of <a>white space</a>,
and/or [=other space separators=],
at the end of a line (after <a href="https://www.w3.org/TR/css-writing-modes/#text-direction">bidi reordering</a> [[CSS-WRITING-MODES-3]]):
<ul>
<li>If 'white-space' is set to ''white-space/normal'', ''white-space/nowrap'', or ''white-space/pre-line'',
the UA must [=hang=] this sequence (unconditionally).
<wpt>
white-space/trailing-ideographic-space-001.html
white-space/trailing-ideographic-space-002.html
white-space/trailing-other-space-separators-001.html
white-space/trailing-other-space-separators-003.html
white-space/trailing-other-space-separators-004.html
text-transform/text-transform-fullwidth-008.html
white-space/white-space-intrinsic-size-019.html
white-space/white-space-intrinsic-size-020.html
</wpt>
<li>If 'white-space' is set to ''pre-wrap'',
the UA must (unconditionally) [=hang=] this sequence,
unless the sequence is followed by a [=forced line break=],
in which case it must [=conditionally hang=] the sequence is instead.
It may also visually collapse the character advance widths
of any that would otherwise overflow.
<wpt>
white-space/pre-wrap-001.html
white-space/pre-wrap-002.html
white-space/pre-wrap-003.html
white-space/pre-wrap-004.html
white-space/pre-wrap-005.html
white-space/pre-wrap-006.html
white-space/pre-wrap-007.html
white-space/pre-wrap-011.html
white-space/pre-wrap-012.html
white-space/pre-wrap-013.html
white-space/pre-wrap-014.html
white-space/pre-wrap-017.html
white-space/pre-wrap-018.html
white-space/pre-wrap-019.html
white-space/pre-wrap-020.html
white-space/textarea-pre-wrap-001.html
white-space/textarea-pre-wrap-002.html
white-space/textarea-pre-wrap-003.html
white-space/textarea-pre-wrap-004.html
white-space/textarea-pre-wrap-005.html
white-space/textarea-pre-wrap-006.html
white-space/textarea-pre-wrap-007.html
white-space/textarea-pre-wrap-011.html
white-space/textarea-pre-wrap-012.html
white-space/textarea-pre-wrap-013.html
white-space/textarea-pre-wrap-014.html
white-space/trailing-ideographic-space-003.html
white-space/trailing-ideographic-space-004.html
white-space/white-space-pre-wrap-trailing-spaces-001.html
white-space/white-space-pre-wrap-trailing-spaces-002.html
white-space/white-space-pre-wrap-trailing-spaces-003.html
white-space/white-space-pre-wrap-trailing-spaces-004.html
white-space/white-space-pre-wrap-trailing-spaces-005.html
white-space/white-space-pre-wrap-trailing-spaces-006.html
white-space/white-space-pre-wrap-trailing-spaces-007.html
white-space/white-space-pre-wrap-trailing-spaces-008.html
white-space/white-space-pre-wrap-trailing-spaces-010.html
white-space/white-space-pre-wrap-trailing-spaces-011.html
white-space/white-space-pre-wrap-trailing-spaces-012.html
white-space/white-space-pre-wrap-trailing-spaces-013.html
white-space/white-space-pre-wrap-trailing-spaces-014.html
white-space/white-space-pre-wrap-trailing-spaces-015.html
white-space/white-space-intrinsic-size-003.html
white-space/white-space-intrinsic-size-004.html
white-space/pre-wrap-tab-005.html
white-space/pre-wrap-tab-006.html
white-space/trailing-other-space-separators-002.html
text-transform/text-transform-fullwidth-009.html
white-space/trailing-space-position-001.html
line-break/line-break-anywhere-and-white-space-006.html
line-break/line-break-anywhere-and-white-space-007.html
white-space/white-space-intrinsic-size-013.html
white-space/white-space-intrinsic-size-014.html
white-space/white-space-intrinsic-size-017.html
white-space/eol-spaces-bidi-002.html
white-space/trailing-space-in-inline-box.html
</wpt>
Note: [=Hanging=] the white space rather than collapsing it
allows users to see the space when selecting or editing text.
<li>If 'white-space' is set to ''break-spaces'',
[=hanging=] or collapsing the advance width of the [=spaces=],
[=tabs=],
or [=other space separators=]
at the end of the line is not allowed;
those that overflow must <a>wrap</a> to the next line.
<wpt>
white-space/break-spaces-001.html
white-space/break-spaces-005.html
white-space/textarea-break-spaces-001.html
white-space/break-spaces-tab-005.html
white-space/break-spaces-tab-006.html
white-space/trailing-other-space-separators-break-spaces-001.html
white-space/trailing-other-space-separators-break-spaces-002.html
white-space/trailing-other-space-separators-break-spaces-003.html
white-space/trailing-other-space-separators-break-spaces-004.html
white-space/trailing-other-space-separators-break-spaces-005.html
white-space/trailing-other-space-separators-break-spaces-006.html
white-space/trailing-other-space-separators-break-spaces-007.html
white-space/trailing-other-space-separators-break-spaces-008.html
white-space/trailing-other-space-separators-break-spaces-009.html
white-space/trailing-other-space-separators-break-spaces-010.html
white-space/trailing-other-space-separators-break-spaces-011.html
white-space/trailing-other-space-separators-break-spaces-012.html
white-space/trailing-other-space-separators-break-spaces-013.html
white-space/trailing-other-space-separators-break-spaces-014.html
white-space/trailing-other-space-separators-break-spaces-015.html
line-break/line-break-anywhere-and-white-space-008.html
line-break/line-break-anywhere-and-white-space-009.html
</wpt>
</ul>
</ol>
<div class=example>
This example shows that [=conditionally hanging=] white space
at the end of lines with forced breaks
provides symmetry with the start of the line.
An underline is added to help visualize the spaces.
<pre><code class=lang-css>
p {
white-space: pre-wrap;
width: 5ch;
border: solid 1px;
font-family: monospace;
text-align: center;
}</code></pre>
<pre><code class=lang-markup>
&lt;p> 0 &lt;/p>
</code></pre>
The sample above would be rendered as follows:
<div style="word-wrap: normal; font-size: 2em; font-family: monospace; width: 5ch; border: solid 1px; white-space: pre;"> <span style="text-decoration: underline; text-decoration: underline orange"> 0 </span> </div>
Since the final [=space=] is before a forced line break
and does not overflow,
it does not hang,
and centering works as expected.
</div>
<div class=example>
This example illustrates the difference
between [=hanging=] [=spaces=]
at the end of lines without forced breaks,
and [=conditionally hanging=] them at the end of lines with forced breaks.
An underline is added to help visualize the [=spaces=].
<pre><code class=lang-css>
p {
white-space: pre-wrap;
width: 3ch;
border: solid 1px;
font-family: monospace;
}</code></pre>
<pre><code class=lang-markup>
&lt;p> 0 0 0 0 &lt;/p>
</code></pre>
The sample above would be rendered as follows:
<div style="word-wrap: normal; font-size: 2em; font-family: monospace; width: 3ch; border: solid 1px; white-space: pre; text-decoration: underline; text-decoration: underline orange"> 0 <br>0 0 <br>0 </div>
If <code class=lang-css>p { text-align: right; }</code> was added,
the result would be as follows:
<div style="word-wrap: normal; font-size: 2em; font-family: monospace; width: 3ch; border: solid 1px; white-space: pre;"> <span style="text-decoration: underline; text-decoration: underline orange"> 0 </span><br><span style="text-decoration: underline; text-decoration: underline orange">0 0 </span><br> <span style="text-decoration: underline; text-decoration: underline orange">0 </span></div>
As the [=preserved=] [=spaces=] at the end of lines without a forced break must [=hang=],
they are not considered when placing the rest of the line during text alignment.
When aligning towards the end,
this means any such [=spaces=] will overflow,
and will not prevent the rest of the line's content from being flush with the edge of the line.
On the other hand,
preserved spaces at the end of a line <em>with</em> a forced break
[=conditionally hang=].
Since the space at the end of the last line would not overflow in this example,
it does not [=hang=]
and therefore is considered during text alignment.
</div>
<div class=example>
In the following example,
there is not enough room on any line to fit the end-of-line spaces,
so they [=hang=] on all lines:
the one on the line without a forced break because it must,
as well as the one on the line with a forced break,
because it [=conditionally hangs=] and overflows.
An underline is added to help visualize the spaces.
<pre><code class=lang-css>
p {
white-space: pre-wrap;
width: 3ch;
border: solid 1px;
font-family: monospace;
}</code></pre>
<pre><code class=lang-markup>
&lt;p>0 0 0 0 &lt;/p>
</code></pre>
<div style="word-wrap: normal; font-size: 2em; font-family: monospace; width: 3ch; border: solid 1px; white-space: pre; text-decoration: underline; text-decoration: underline orange">0 0 <br>0 0 </div>
The last line is not wrapped before the last <code>0</code>
because characters that [=conditionally hang=] are not considered
when measuring the line’s contents for fit.
</div>
<h4 id="line-break-transform">
Segment Break Transformation Rules</h4>
<p>When 'white-space' is ''pre'', ''pre-wrap'', ''break-spaces'', or ''pre-line'',
<a>segment breaks</a> are not <a>collapsible</a>
and are instead transformed into a preserved line feed (U+000A).
<wpt pathprefix="/css/CSS2/text/">
white-space-008.xht
white-space-processing-016.xht
white-space-processing-017.xht
white-space-processing-018.xht
</wpt>
<p>For other values of 'white-space', <a>segment breaks</a> are <a>collapsible</a>,
and are collapsed as follows:
<ol>
<li>First, any collapsible <a>segment break</a> immediately following another collapsible <a>segment break</a>
is removed.
<li>Then any remaining <a>segment break</a> is
either transformed into a space (U+0020) or removed
depending on the context before and after the break.
The rules for this operation are UA-defined in this level.
<!-- CUT SEGMENT BREAK TRANSFORM
<wpt pathprefix="/css/vendor-imports/mozilla/mozilla-central-reftests/text3/">
segment-break-transformation-removable-2.html
segment-break-transformation-removable-4.html
</wpt>
<wpt>
white-space/seg-break-transformation-000.html
</wpt>
<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.
<wpt>
white-space/seg-break-transformation-016.html
white-space/seg-break-transformation-017.html
white-space/seg-break-transformation-018.html
white-space/seg-break-transformation-019.html
</wpt>
<wpt pathprefix="/css/vendor-imports/mozilla/mozilla-central-reftests/text3/">
segment-break-transformation-removable-1.html
segment-break-transformation-removable-3.html
</wpt>
<li>Otherwise, if both the characters before and after the [=segment break=]
belong to the [=space-discarding character set=] (see [[#space-discard-set]]),
then the [=segment break=] is removed.
<li>Otherwise, if the <a>East Asian Width property</a> [[!UAX11]] of both
the character before and after the [=segment break=] is
<code>Fullwidth</code>, <code>Wide</code>, or <code>Halfwidth</code>
(not <code>Ambiguous</code>),
and neither side is Hangul,
then the [=segment break=] is removed.
<wpt>
white-space/seg-break-transformation-001.html
white-space/seg-break-transformation-002.html
white-space/seg-break-transformation-003.html
white-space/seg-break-transformation-004.html
white-space/seg-break-transformation-005.html
white-space/seg-break-transformation-006.html
white-space/seg-break-transformation-007.html
white-space/seg-break-transformation-008.html
white-space/seg-break-transformation-009.html
white-space/seg-break-transformation-010.html
white-space/seg-break-transformation-011.html
white-space/seg-break-transformation-012.html
white-space/seg-break-transformation-014.html
white-space/seg-break-transformation-015.html
</wpt>
<wpt pathprefix="/css/vendor-imports/mozilla/mozilla-central-reftests/text3/">
segment-break-transformation-rules-001.html
segment-break-transformation-rules-002.html
segment-break-transformation-rules-003.html
segment-break-transformation-rules-004.html
segment-break-transformation-rules-005.html
segment-break-transformation-rules-006.html
segment-break-transformation-rules-007.html
segment-break-transformation-rules-008.html
segment-break-transformation-rules-009.html
segment-break-transformation-rules-010.html
segment-break-transformation-rules-011.html
segment-break-transformation-rules-012.html
segment-break-transformation-rules-013.html
segment-break-transformation-rules-014.html
segment-break-transformation-rules-015.html
segment-break-transformation-rules-016.html
segment-break-transformation-rules-017.html
segment-break-transformation-rules-018.html
segment-break-transformation-rules-019.html
segment-break-transformation-rules-020.html
segment-break-transformation-rules-021.html
segment-break-transformation-rules-022.html
segment-break-transformation-rules-023.html
segment-break-transformation-rules-024.html
segment-break-transformation-rules-025.html
segment-break-transformation-rules-026.html
segment-break-transformation-rules-027.html
segment-break-transformation-rules-028.html
segment-break-transformation-rules-029.html
segment-break-transformation-rules-030.html
segment-break-transformation-rules-031.html
segment-break-transformation-rules-032.html
segment-break-transformation-rules-033.html
segment-break-transformation-rules-034.html
segment-break-transformation-rules-035.html
segment-break-transformation-rules-036.html
segment-break-transformation-rules-037.html
segment-break-transformation-rules-038.html
segment-break-transformation-rules-039.html
segment-break-transformation-rules-040.html
segment-break-transformation-rules-041.html
segment-break-transformation-rules-042.html
segment-break-transformation-rules-043.html
segment-break-transformation-rules-044.html
segment-break-transformation-rules-045.html
segment-break-transformation-rules-046.html
segment-break-transformation-rules-047.html
segment-break-transformation-rules-048.html
segment-break-transformation-rules-049.html
</wpt>
<li>Otherwise, if the <a>writing system</a> of the <a>segment break</a>
is <a for=writing-system>Chinese</a>, <a for=writing-system>Japanese</a>, or Yi,
and the character before or after the [=segment break=]
is punctuation or a symbol (Unicode <a>general category</a> P* or S*)
and has an <a>East Asian Width property</a> of <code>Ambiguous</code>,
and the character on the other side of the [=segment break=] is
<code>Fullwidth</code>, <code>Wide</code>, or <code>Halfwidth</code>,
and not Hangul,
then the [=segment break=] is removed.
<wpt>
writing-system/writing-system-segment-break-001.html
</wpt>
<li>Otherwise, the [=segment break=] is converted to a space (U+0020).
<wpt>
white-space/seg-break-transformation-000.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-processing-005.xht
white-space-processing-014.xht
white-space-processing-015.xht
</wpt>
</ul>
<p>
For this purpose,
Emoji (Unicode property <code>Emoji</code>)
with an <a>East Asian Width property</a> of
<code>Wide</code> or <code>Neutral</code>
are treated as having an <a>East Asian Width property</a> of
<code>Ambiguous</code>.
ISSUE(5086): Should space-discarding punctuation have a stronger influence over mismatched before/after contexts?
ISSUE(5017): Should we classify punctuation and/or symbols as a category of space-ambiguous characters? (Currently spaces are discarded only if both sides are space-discarding; ambiguous characters would defer to the other side.)
CUT SEGMENT BREAK TRANSFORM -->
Note: The white space processing rules have already
removed any [=tabs=] and [=spaces=] around the [=segment break=]
before this context is evaluated.
</ol>
<div class="example">
The purpose of the segment break transformation rules
(and white space collapsing in general)
is to “unbreak” text that has been
<a href="#white-space-processing">broken into segments</a>
to make the document source code easier to work with.
In languages that use word separators, such as English and Korean,
“unbreaking” a line requires joining the two lines with a [=space=].
<figure>
<pre>
Here is an English paragraph
that is broken into multiple lines
in the source code so that it can
be more easily read and edited
in a text editor.
</pre>
<p>Here is an English paragraph that is broken into multiple lines in the source code so that it can be more easily read and edited in a text editor.</p>
<figcaption>
Eliminating a line break in English requires maintaining a [=space=] in its place.
</figcaption>
</figure>
In languages that have no word separators, such as Chinese,
“unbreaking” a line requires joining the two lines with no intervening space.
<figure>
<pre lang="zh-Hant">
這個段落是那麼長,
在一行寫不行。最好
用三行寫。
</pre>
<p lang="zh-Hant">這個段落是那麼長,在一行寫不行。最好用三行寫。</p>
<figcaption>
Eliminating a line break in Chinese requires eliminating any intervening [=white space=].
</figcaption>
</figure>
The segment break transformation rules can use adjacent context
to either transform the segment break into a space
or eliminate it entirely.
</div>
Note: Historically, HTML and CSS have unconditionally converted [=segment breaks=] to spaces,
which has prevented content authored in languages such as Chinese
from being able to break lines within the source.
Thus UA heurstics need to be conservative about where they discard [=segment breaks=]
even as they strive to improve support for such languages.
<h3 id="tab-size-property" caniuse="css3-tabsize" oldids="tab-size">
Tab Character Size: the 'tab-size' property</h3>
<pre class="propdef">
Name: tab-size
Value: <<number>> | <<length>>
Initial: 8
Applies to: inline boxes
Inherited: yes
Computed value: the specified number or absolute length
Animation type: by computed value type
Canonical order: n/a
</pre>
<wpt>
tab-size/tab-size-integer-001.html
tab-size/tab-size.html
tab-size/tab-size-inheritance-001.html
inheritance.html
parsing/tab-size-valid.html
parsing/tab-size-invalid.html
parsing/tab-size-computed.html
tab-size/tab-size-inline-001.html
animations/tab-size-interpolation.html
</wpt>
<p>This property determines the <dfn id=tab-size-dfn>tab size</dfn> used to render [=preserved=] tab characters (U+0009).
A <<number>> represents the measure as a multiple of the advance width of the space character (U+0020)
of the nearest [=block container=] ancestor of the [=preserved=] [=tab=],
including its associated 'letter-spacing' and 'word-spacing'.
Negative values are not allowed.
<wpt>
tab-size/tab-size-integer-001.html
tab-size/tab-size-integer-002.html
tab-size/tab-size-integer-003.html
tab-size/tab-size-integer-004.html
tab-size/tab-size-length-001.html
tab-size/tab-size-length-002.html
tab-size/tab-size-percent-001.html
tab-size/tab-min-rendered-width-1.html
tab-size/tab-size-spacing-001.html
white-space/tab-stop-threshold-001.html
white-space/tab-stop-threshold-002.html
white-space/tab-stop-threshold-003.html
white-space/tab-stop-threshold-004.html
white-space/tab-stop-threshold-005.html
white-space/tab-stop-threshold-006.html
text-indent/text-indent-tab-positions-001.html
</wpt>
<wpt pathprefix="/css/CSS2/text/">
white-space-processing-042.xht
</wpt>
<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 export>line break</dfn>.
When a line is broken due to explicit line-breaking controls
(such as a <a>preserved</a> newline character),
or due to the start or end of a block,
it is a <dfn export>forced line break</dfn>.
When a line is broken due to content <dfn lt="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 export lt="line breaking process | line breaking">line breaking</dfn>.
<p>Wrapping is only performed at an allowed break point,
called a <dfn export>soft wrap opportunity</dfn>.
When wrapping is enabled (see 'white-space'),
the UA must minimize the amount of content overflowing a line
by wrapping the line at a <a>soft wrap opportunity</a>,
if one exists.
<wpt>
line-breaking/line-breaking-020.html
</wpt>
<p>In most writing systems,
in the absence of hyphenation a <a>soft wrap opportunity</a> occurs only at word boundaries.
Many such systems use [=spaces=] or punctuation to explicitly separate words,
and <a>soft wrap opportunities</a> 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 <a>soft wrap opportunities</a> in such texts.
<p>In some other writing systems,
<a>soft wrap opportunities</a> are based on orthographic syllable boundaries,
not word boundaries.
Some of these systems, such as Javanese and Balinese,
are similar to Thai and Lao in that they
require analysis of the text to find breaking opportunities.
In others such as Chinese (as well as Japanese, Yi, and sometimes also Korean),
each syllable tends to correspond to a single <a>typographic letter unit</a>,
and thus line breaking conventions allow the line to break
anywhere <em>except</em> between certain character combinations.
Additionally the level of strictness in these restrictions
varies with the typesetting style.
<wpt>
i18n/css3-text-line-break-baspglwj-003.html
i18n/css3-text-line-break-baspglwj-004.html
i18n/css3-text-line-break-baspglwj-005.html
i18n/css3-text-line-break-baspglwj-006.html
i18n/css3-text-line-break-baspglwj-007.html
i18n/css3-text-line-break-baspglwj-008.html
i18n/css3-text-line-break-baspglwj-009.html
i18n/css3-text-line-break-baspglwj-010.html
i18n/css3-text-line-break-baspglwj-011.html
i18n/css3-text-line-break-baspglwj-012.html
i18n/css3-text-line-break-baspglwj-014.html
i18n/css3-text-line-break-baspglwj-015.html
i18n/css3-text-line-break-baspglwj-016.html
i18n/css3-text-line-break-baspglwj-017.html
i18n/css3-text-line-break-baspglwj-018.html
i18n/css3-text-line-break-baspglwj-019.html
i18n/css3-text-line-break-baspglwj-020.html
i18n/css3-text-line-break-baspglwj-021.html
i18n/css3-text-line-break-baspglwj-022.html
i18n/css3-text-line-break-baspglwj-023.html
i18n/css3-text-line-break-baspglwj-024.html
i18n/css3-text-line-break-baspglwj-025.html
i18n/css3-text-line-break-baspglwj-026.html
i18n/css3-text-line-break-baspglwj-030.html
i18n/css3-text-line-break-baspglwj-031.html
i18n/css3-text-line-break-baspglwj-032.html
i18n/css3-text-line-break-baspglwj-033.html
i18n/css3-text-line-break-baspglwj-034.html
i18n/css3-text-line-break-baspglwj-035.html
i18n/css3-text-line-break-baspglwj-036.html
i18n/css3-text-line-break-baspglwj-037.html
i18n/css3-text-line-break-baspglwj-038.html
i18n/css3-text-line-break-baspglwj-039.html
i18n/css3-text-line-break-baspglwj-040.html
i18n/css3-text-line-break-baspglwj-041.html
i18n/css3-text-line-break-baspglwj-042.html
i18n/css3-text-line-break-baspglwj-043.html
i18n/css3-text-line-break-baspglwj-044.html
i18n/css3-text-line-break-baspglwj-045.html
i18n/css3-text-line-break-baspglwj-046.html
i18n/css3-text-line-break-baspglwj-047.html
i18n/css3-text-line-break-baspglwj-048.html
i18n/css3-text-line-break-baspglwj-049.html
i18n/css3-text-line-break-baspglwj-050.html
i18n/css3-text-line-break-baspglwj-051.html
i18n/css3-text-line-break-baspglwj-052.html
i18n/css3-text-line-break-baspglwj-060.html
i18n/css3-text-line-break-baspglwj-061.html
i18n/css3-text-line-break-baspglwj-062.html
i18n/css3-text-line-break-baspglwj-063.html
i18n/css3-text-line-break-baspglwj-064.html
i18n/css3-text-line-break-baspglwj-065.html
i18n/css3-text-line-break-baspglwj-066.html
i18n/css3-text-line-break-baspglwj-067.html
i18n/css3-text-line-break-baspglwj-068.html
i18n/css3-text-line-break-baspglwj-069.html
i18n/css3-text-line-break-baspglwj-070.html
i18n/css3-text-line-break-baspglwj-071.html
i18n/css3-text-line-break-baspglwj-072.html
i18n/css3-text-line-break-baspglwj-073.html
i18n/css3-text-line-break-baspglwj-074.html
i18n/css3-text-line-break-baspglwj-075.html
i18n/css3-text-line-break-baspglwj-076.html
i18n/css3-text-line-break-baspglwj-077.html
i18n/css3-text-line-break-baspglwj-078.html
i18n/css3-text-line-break-baspglwj-080.html
i18n/css3-text-line-break-baspglwj-081.html
i18n/css3-text-line-break-baspglwj-082.html
i18n/css3-text-line-break-baspglwj-083.html
i18n/css3-text-line-break-baspglwj-084.html
i18n/css3-text-line-break-baspglwj-085.html
i18n/css3-text-line-break-baspglwj-086.html
i18n/css3-text-line-break-baspglwj-090.html
i18n/css3-text-line-break-baspglwj-091.html
i18n/css3-text-line-break-baspglwj-092.html
i18n/css3-text-line-break-baspglwj-093.html
i18n/css3-text-line-break-baspglwj-095.html
i18n/css3-text-line-break-baspglwj-096.html
i18n/css3-text-line-break-baspglwj-097.html
i18n/css3-text-line-break-baspglwj-098.html
i18n/css3-text-line-break-baspglwj-099.html
i18n/css3-text-line-break-baspglwj-100.html
i18n/css3-text-line-break-baspglwj-101.html
i18n/css3-text-line-break-baspglwj-102.html
i18n/css3-text-line-break-baspglwj-103.html
i18n/css3-text-line-break-baspglwj-104.html
i18n/css3-text-line-break-baspglwj-105.html
i18n/css3-text-line-break-baspglwj-106.html
i18n/css3-text-line-break-baspglwj-107.html
i18n/css3-text-line-break-baspglwj-108.html
i18n/css3-text-line-break-baspglwj-109.html
i18n/css3-text-line-break-baspglwj-110.html
i18n/css3-text-line-break-baspglwj-111.html
i18n/css3-text-line-break-baspglwj-112.html
i18n/css3-text-line-break-baspglwj-113.html
i18n/css3-text-line-break-baspglwj-114.html
i18n/css3-text-line-break-baspglwj-115.html
i18n/css3-text-line-break-baspglwj-116.html
i18n/css3-text-line-break-baspglwj-117.html
i18n/css3-text-line-break-baspglwj-118.html
i18n/css3-text-line-break-opclns-001.html
i18n/css3-text-line-break-opclns-002.html
i18n/css3-text-line-break-opclns-003.html
i18n/css3-text-line-break-opclns-004.html
i18n/css3-text-line-break-opclns-005.html
i18n/css3-text-line-break-opclns-006.html
i18n/css3-text-line-break-opclns-007.html
i18n/css3-text-line-break-opclns-008.html
i18n/css3-text-line-break-opclns-009.html
i18n/css3-text-line-break-opclns-010.html
i18n/css3-text-line-break-opclns-011.html
i18n/css3-text-line-break-opclns-012.html
i18n/css3-text-line-break-opclns-014.html
i18n/css3-text-line-break-opclns-015.html
i18n/css3-text-line-break-opclns-016.html
i18n/css3-text-line-break-opclns-017.html
i18n/css3-text-line-break-opclns-018.html
i18n/css3-text-line-break-opclns-019.html
i18n/css3-text-line-break-opclns-020.html
i18n/css3-text-line-break-opclns-021.html
i18n/css3-text-line-break-opclns-022.html
i18n/css3-text-line-break-opclns-023.html
i18n/css3-text-line-break-opclns-024.html
i18n/css3-text-line-break-opclns-025.html
i18n/css3-text-line-break-opclns-026.html
i18n/css3-text-line-break-opclns-027.html
i18n/css3-text-line-break-opclns-028.html
i18n/css3-text-line-break-opclns-029.html
i18n/css3-text-line-break-opclns-030.html
i18n/css3-text-line-break-opclns-031.html
i18n/css3-text-line-break-opclns-032.html
i18n/css3-text-line-break-opclns-033.html
i18n/css3-text-line-break-opclns-034.html
i18n/css3-text-line-break-opclns-035.html
i18n/css3-text-line-break-opclns-036.html
i18n/css3-text-line-break-opclns-037.html
i18n/css3-text-line-break-opclns-038.html
i18n/css3-text-line-break-opclns-039.html
i18n/css3-text-line-break-opclns-040.html
i18n/css3-text-line-break-opclns-041.html
i18n/css3-text-line-break-opclns-042.html
i18n/css3-text-line-break-opclns-043.html
i18n/css3-text-line-break-opclns-044.html
i18n/css3-text-line-break-opclns-045.html
i18n/css3-text-line-break-opclns-046.html
i18n/css3-text-line-break-opclns-047.html
i18n/css3-text-line-break-opclns-049.html
i18n/css3-text-line-break-opclns-050.html
i18n/css3-text-line-break-opclns-051.html
i18n/css3-text-line-break-opclns-052.html
i18n/css3-text-line-break-opclns-053.html
i18n/css3-text-line-break-opclns-054.html
i18n/css3-text-line-break-opclns-055.html
i18n/css3-text-line-break-opclns-056.html
i18n/css3-text-line-break-opclns-057.html
i18n/css3-text-line-break-opclns-058.html
i18n/css3-text-line-break-opclns-059.html
i18n/css3-text-line-break-opclns-060.html
i18n/css3-text-line-break-opclns-061.html
i18n/css3-text-line-break-opclns-062.html
i18n/css3-text-line-break-opclns-063.html
i18n/css3-text-line-break-opclns-064.html
i18n/css3-text-line-break-opclns-065.html
i18n/css3-text-line-break-opclns-100.html
i18n/css3-text-line-break-opclns-101.html
i18n/css3-text-line-break-opclns-102.html
i18n/css3-text-line-break-opclns-103.html
i18n/css3-text-line-break-opclns-104.html
i18n/css3-text-line-break-opclns-105.html
i18n/css3-text-line-break-opclns-106.html
i18n/css3-text-line-break-opclns-107.html
i18n/css3-text-line-break-opclns-108.html
i18n/css3-text-line-break-opclns-109.html
i18n/css3-text-line-break-opclns-110.html
i18n/css3-text-line-break-opclns-111.html
i18n/css3-text-line-break-opclns-112.html
i18n/css3-text-line-break-opclns-113.html
i18n/css3-text-line-break-opclns-114.html
i18n/css3-text-line-break-opclns-115.html
i18n/css3-text-line-break-opclns-116.html
i18n/css3-text-line-break-opclns-117.html
i18n/css3-text-line-break-opclns-119.html
i18n/css3-text-line-break-opclns-120.html
i18n/css3-text-line-break-opclns-121.html
i18n/css3-text-line-break-opclns-122.html
i18n/css3-text-line-break-opclns-123.html
i18n/css3-text-line-break-opclns-124.html
i18n/css3-text-line-break-opclns-125.html
i18n/css3-text-line-break-opclns-126.html
i18n/css3-text-line-break-opclns-127.html
i18n/css3-text-line-break-opclns-128.html
i18n/css3-text-line-break-opclns-129.html
i18n/css3-text-line-break-opclns-130.html
i18n/css3-text-line-break-opclns-131.html
i18n/css3-text-line-break-opclns-132.html
i18n/css3-text-line-break-opclns-133.html
i18n/css3-text-line-break-opclns-134.html
i18n/css3-text-line-break-opclns-135.html
i18n/css3-text-line-break-opclns-136.html
i18n/css3-text-line-break-opclns-137.html
i18n/css3-text-line-break-opclns-138.html
i18n/css3-text-line-break-opclns-139.html
i18n/css3-text-line-break-opclns-140.html
i18n/css3-text-line-break-opclns-141.html
i18n/css3-text-line-break-opclns-142.html
i18n/css3-text-line-break-opclns-143.html
i18n/css3-text-line-break-opclns-144.html
i18n/css3-text-line-break-opclns-145.html
i18n/css3-text-line-break-opclns-146.html
i18n/css3-text-line-break-opclns-147.html
i18n/css3-text-line-break-opclns-148.html
i18n/css3-text-line-break-opclns-149.html
i18n/css3-text-line-break-opclns-150.html
i18n/css3-text-line-break-opclns-151.html
i18n/css3-text-line-break-opclns-152.html
i18n/css3-text-line-break-opclns-153.html
i18n/css3-text-line-break-opclns-155.html
i18n/css3-text-line-break-opclns-156.html
i18n/css3-text-line-break-opclns-157.html
i18n/css3-text-line-break-opclns-158.html
i18n/css3-text-line-break-opclns-159.html
i18n/css3-text-line-break-opclns-160.html
i18n/css3-text-line-break-opclns-161.html
i18n/css3-text-line-break-opclns-162.html
i18n/css3-text-line-break-opclns-163.html
i18n/css3-text-line-break-opclns-164.html
i18n/css3-text-line-break-opclns-165.html
i18n/css3-text-line-break-opclns-166.html
i18n/css3-text-line-break-opclns-167.html
i18n/css3-text-line-break-opclns-168.html
i18n/css3-text-line-break-opclns-169.html
i18n/css3-text-line-break-opclns-170.html
i18n/css3-text-line-break-opclns-171.html
i18n/css3-text-line-break-opclns-200.html
i18n/css3-text-line-break-opclns-201.html
i18n/css3-text-line-break-opclns-202.html
i18n/css3-text-line-break-opclns-203.html
i18n/css3-text-line-break-opclns-204.html
i18n/css3-text-line-break-opclns-205.html
i18n/css3-text-line-break-opclns-206.html
i18n/css3-text-line-break-opclns-207.html
i18n/css3-text-line-break-opclns-208.html
i18n/css3-text-line-break-opclns-209.html
i18n/css3-text-line-break-opclns-210.html
i18n/css3-text-line-break-opclns-211.html
i18n/css3-text-line-break-opclns-212.html
i18n/css3-text-line-break-opclns-213.html
i18n/css3-text-line-break-opclns-214.html
i18n/css3-text-line-break-opclns-215.html
i18n/css3-text-line-break-opclns-217.html
i18n/css3-text-line-break-opclns-218.html
i18n/css3-text-line-break-opclns-219.html
i18n/css3-text-line-break-opclns-220.html
i18n/css3-text-line-break-opclns-221.html
i18n/css3-text-line-break-opclns-222.html
i18n/css3-text-line-break-opclns-223.html
i18n/css3-text-line-break-opclns-225.html
i18n/css3-text-line-break-opclns-226.html
</wpt>
<p>While CSS does not fully define where <a>soft wrap opportunities</a> occur,
some controls are provided to distinguish common variations:
<ul>
<li>
The 'line-break' property allows choosing various levels of “strictness”
for line breaking restrictions.
<li>
The 'word-break' property controls what types of letters
are glommed together to form unbreakable “words”,
causing CJK characters to behave like non-CJK text or vice versa.
<li>
The 'hyphens' property controls whether automatic hyphenation
is allowed to break words in scripts that hyphenate.
<li>
The 'overflow-wrap' property allows the UA to take a break anywhere
in otherwise-unbreakable strings that would otherwise overflow.
</ul>
<div class="note">
<p>
Note: [[UAX14]] defines a baseline behavior
for line breaking for all scripts in Unicode,
which is expected to be further tailored.
More information on line breaking conventions
can be found in [[JLREQ]] and [[JIS4051]] for Japanese,
[[CLREQ]] and [[ZHMARK]] for Chinese.
See also the
<a href="https://www.w3.org/International/">Internationalization Working Group</a>’s
<a href="https://www.w3.org/TR/typography/#blocks_paragraphs">Typography Index</a> [[TYPOGRAPHY]]
which includes more information on additional languages.
<p class="feedback issue">Any guidance for additional appropriate references
would be much appreciated.
</div>
<h3 id="line-break-details">
Line Breaking Details</h3>
<p>When determining <a>line breaks</a>:
<ul>
<li>The interaction of [=line breaking=] and bidirectional text is defined by
[[!CSS-WRITING-MODES-3]] and [[!UAX9]],
see in particular [[css-writing-modes-3#bidi-algo]]
and <a href="http://unicode.org/reports/tr9/#Reordering_Resolved_Levels">UAX9&sect;3.4 Reordering Resolved Levels</a>.
<wpt pathprefix="/css/CSS2/bidi-text/">
bidi-breaking-001.xht
bidi-breaking-002.xht
bidi-breaking-003.xht
</wpt>
<li>Regardless of the 'white-space' value,
lines always break at each <a>preserved</a> forced break character:
thus
for all values, line-breaking behavior defined for
the <code>BK</code> and <code>NL</code> Unicode line breaking classes [[!UAX14]]
must be honored.
Note: The bidi implications of such [=forced line breaks=] are defined by [[!UAX9]].
<li>Except where explicitly defined otherwise
(e.g. for ''line-break: anywhere'' or ''overflow-wrap: anywhere'')
line breaking behavior defined for
the <code>WJ</code>, <code>ZW</code>, <code>GL</code>, and <code>ZWJ</code> Unicode line breaking classes [[!UAX14]]
must be honored.
<wpt>
word-break/word-break-normal-001.html
line-breaking/line-breaking-001.html
line-breaking/line-breaking-002.html
line-breaking/line-breaking-003.html
line-breaking/line-breaking-004.html
line-breaking/line-breaking-005.html
line-breaking/line-breaking-006.html
line-breaking/line-breaking-007.html
line-breaking/line-breaking-008.html
line-breaking/line-breaking-021.html
i18n/css3-text-line-break-baspglwj-001.html
i18n/css3-text-line-break-baspglwj-002.html
i18n/css3-text-line-break-baspglwj-120.html
i18n/css3-text-line-break-baspglwj-121.html
i18n/css3-text-line-break-baspglwj-122.html
i18n/css3-text-line-break-baspglwj-123.html
i18n/css3-text-line-break-baspglwj-124.html
i18n/css3-text-line-break-baspglwj-125.html
i18n/css3-text-line-break-baspglwj-126.html
i18n/css3-text-line-break-baspglwj-127.html
i18n/css3-text-line-break-baspglwj-128.html
i18n/css3-text-line-break-baspglwj-130.html
i18n/css3-text-line-break-baspglwj-131.html
word-break/word-break-break-all-018.html
word-break/word-break-break-all-021.html
word-break/word-break-break-all-022.html
</wpt>
<li>UAs that allow wrapping at punctuation
other than <a>word separators</a>
in writing systems that use them
<em>should</em> 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".)
As long as care is taken to avoid such awkward breaks,
allowing breaks at appropriate punctuation other than <a>word separators</a>
is recommended,
as it results in more even-looking margins, particularly in narrow measures.
The UA may use the width of the containing block, the text's language,
the 'line-break' value,
and other factors in assigning priorities:
CSS does not define prioritization of line breaking opportunities.
Prioritization of <a>word separators</a> is not expected,
however,
if ''word-break: break-all'' is specified
(since this value explicitly requests line breaking behavior
not based on breaking at <a>word separators</a>)--
and is forbidden under ''line-break: anywhere''.
<li>Out-of-flow elements
and inline element boundaries
do not introduce a <a>forced line break</a>
or <a>soft wrap opportunity</a> in the flow.
<wpt>
line-breaking/line-breaking-012.html
line-breaking/line-breaking-015.html
line-breaking/line-breaking-016.html
line-breaking/line-breaking-017.html
line-breaking/line-breaking-018.html
line-breaking/line-breaking-019.html
</wpt>
<li>For Web-compatibility
there is a [=soft wrap opportunity=]
before and after each replaced element or other [=atomic inline=],
even when adjacent to a character that would normally suppress them,
such as U+00A0 NO-BREAK SPACE.
<wpt>
line-breaking/line-breaking-atomic-001.html
line-breaking/line-breaking-atomic-002.html
line-breaking/line-breaking-atomic-003.html
line-breaking/line-breaking-atomic-004.html
line-breaking/line-breaking-atomic-005.html
line-breaking/line-breaking-atomic-006.html
line-breaking/line-breaking-atomic-007.html
line-breaking/line-breaking-atomic-008.html
line-breaking/line-breaking-atomic-009.html
line-breaking/line-breaking-replaced-001.html
line-breaking/line-breaking-replaced-002.html
line-breaking/line-breaking-replaced-003.html
line-breaking/line-breaking-replaced-004.html
line-breaking/line-breaking-replaced-005.html
line-breaking/line-breaking-replaced-006.html
line-breaking/line-breaking-atomic-nowrap-001.html
</wpt>
<li>For <a>soft wrap opportunities</a> created by characters that disappear at the line break (e.g. U+0020 SPACE),
properties on the box directly containing that character control the line breaking at that opportunity.
For <a>soft wrap opportunities</a> defined by the boundary between two characters,
the 'white-space' property on the nearest common ancestor of the two characters controls breaking;
<!-- http://lists.w3.org/Archives/Public/www-style/2008Dec/0043.html -->
which elements’ 'line-break', 'word-break', and 'overflow-wrap' properties
control the determination of [=soft wrap opportunities=]
at such boundaries
is undefined in Level 3.
<wpt>
line-breaking/line-breaking-009.html
line-breaking/line-breaking-010.html
line-breaking/line-breaking-011.html
line-breaking/line-breaking-ic-001.html
line-breaking/line-breaking-ic-002.html
line-breaking/line-breaking-ic-003.html
white-space/white-space-wrap-after-nowrap-001.html
word-break/word-break-break-all-inline-010.html
overflow-wrap/overflow-wrap-anywhere-inline-003.html
</wpt>
<li>For <a>soft wrap opportunities</a> 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>Line breaking in/around Ruby is defined in <a href="https://www.w3.org/TR/css-ruby-1/#line-breaks">CSS Ruby</a> [[!CSS-RUBY-1]].
<li>In order to avoid unexpected overflow,
if the User Agent is unable to perform the requisite lexical or orthographic analysis
for line breaking any [=content language=] that requires it--
for example due to lacking a dictionary for certain languages--
it must assume a [=soft wrap opportunity=]
between pairs of [=typographic letter units=] in that writing system.
Note: This provision is not triggered merely when
the UA fails to find a word boundary in a particular text run;
the text run may well be a single unbreakable word.
It applies for example
when a text run is composed of Khmer characters (U+1780 to U+17FF)
if the User Agent does not know how to determine
word boundaries in Khmer.
</ul>
<h3 id="word-break-property" caniuse="word-break" oldids="word-break">
Breaking Rules for Letters: the 'word-break' property</h3>
<pre class="propdef">
Name: word-break
Value: normal | keep-all | break-all | break-word
Initial: normal
Applies to: <a>inline boxes</a>
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
</pre>
<wpt>
inheritance.html
parsing/word-break-invalid.html
parsing/word-break-valid.html
parsing/word-break-computed.html
word-break/word-break-break-all-inline-001.html
word-break/word-break-break-all-inline-002.html
word-break/word-break-break-all-inline-003.html
word-break/word-break-break-all-inline-004.html
word-break/word-break-break-all-inline-005.html
word-break/word-break-break-all-inline-006.html
word-break/word-break-break-all-inline-007.html
word-break/word-break-break-all-inline-009.html
word-break/word-break-break-all-062.html
word-break/word-break-keep-all-063.html
</wpt>
<p>This property specifies <a>soft wrap opportunities</a> between letters,
i.e. where it is “normal” and permissible to break lines of text.
Specifically it controls whether a <a>soft wrap opportunity</a>
generally exists
between adjacent <a>typographic letter units</a>,
treating non-<a>letter</a> <a>typographic character units</a>
belonging to the
<code>NU</code>, <code>AL</code>, <code>AI</code>, or <code>ID</code>
Unicode line breaking classes [[!UAX14]]
as <a>typographic letter units</a> for this purpose (only).
It does not affect rules governing the <a>soft wrap opportunities</a>
created by [=white space=] (as well as by [=other space separators=]) and around punctuation.
(See 'line-break' for controls affecting punctuation and small kana.)
<wpt>
word-break/word-break-break-all-010.html
word-break/word-break-break-all-020.html
word-break/word-break-keep-all-005.html
word-break/word-break-keep-all-006.html
word-break/word-break-keep-all-007.html
word-break/word-break-keep-all-008.html
word-break/word-break-break-all-012.html
word-break/word-break-break-all-013.html
word-break/word-break-break-all-015.html
word-break/word-break-break-all-016.html
word-break/word-break-break-all-019.html
word-break/word-break-break-all-020.html
word-break/word-break-break-all-023.html
word-break/word-break-break-all-024.html
word-break/word-break-break-all-025.html
word-break/word-break-break-all-026.html
word-break/word-break-break-all-027.html
word-break/word-break-break-all-028.html
word-break/word-break-break-all-inline-008.html
white-space/break-spaces-008.html
word-break/word-break-min-content-003.html
</wpt>
<div class="example">
<p>For example, in some styles of CJK typesetting, English words are allowed
to break between any two letters, rather than only at spaces or hyphenation points;
this can be enabled with ''word-break:break-all''.
<div class="figure">
<img src="images/break-all.png" alt="A snippet of Japanese text with English in it. The word 'caption' is broken into 'capt' and 'ion' across two lines.">
<p class="caption">An example of English text embedded in Japanese
being broken at an arbitrary point in the word.
</div>
<p>As another example, Korean has two styles of line-breaking:
between any two Korean syllables (''word-break: normal'')
or, like English, mainly at spaces (''word-break: keep-all'').
<pre>
각 줄의 마지막에 한글이 올 때 줄 나눔 <strong>
준을</strong> “글자” 또는 “어절” 단위로 한다.</pre>
<pre>
각 줄의 마지막에 한글이 올 때 줄 나눔
<strong>기준을</strong> “글자” 또는 “어절” 단위로 한다.</pre>
<p>Ethiopic similarly has two styles of line-breaking,
either only breaking at [=word separators=] (''word-break: normal''),
or also allowing breaks between letters within a word (''word-break: break-all'').
<pre>
ተወልዱ፡ኵሉ፡ሰብእ፡ግዑዛን፡ወዕሩያን፡
<strong>በማዕረግ</strong>፡ወብሕግ።ቦሙ፡ኅሊና፡ወዐቅል፡
ወይትጌበሩ፡አሐዱ፡ምስለ፡አሀዱ፡
በመንፈሰ፡እኍና።
</pre>
<pre>
ተወልዱ፡ኵሉ፡ሰብእ፡ግዑዛን፡ወዕሩያን፡<strong>በማ
ዕረግ</strong>፡ወብሕግ።ቦሙ፡ኅሊና፡ወዐቅል፡ወይትጌ
በሩ፡አሐዱ፡ምስለ፡አሀዱ፡በመንፈሰ፡እኍና።
</pre>
</div>
<p class="note">
Note: To enable additional break opportunities only in the case of overflow,
see 'overflow-wrap'.
<p>Values have the following meanings:</p>
<dl dfn-for=word-break dfn-type=value>
<dt><dfn>normal</dfn></dt>
<dd>Words break according to their customary rules,
as described <a href="#line-breaking">above</a>.
Korean, which commonly exhibits two different behaviors,
allows breaks between any two consecutive Hangul/Hanja.
For Ethiopic, which also exhibits two different behaviors,
such breaks within words are not allowed.
<wpt>
word-break/word-break-normal-ar-000.html
word-break/word-break-normal-bo-000.html
word-break/word-break-normal-en-000.html
word-break/word-break-normal-hi-000.html
word-break/word-break-normal-ja-000.html
word-break/word-break-normal-ja-001.html
word-break/word-break-normal-ja-002.html
word-break/word-break-normal-ja-004.html
word-break/word-break-normal-km-000.html
word-break/word-break-normal-ko-000.html
word-break/word-break-normal-lo-000.html
word-break/word-break-normal-my-000.html
word-break/word-break-normal-tdd-000.html
word-break/word-break-normal-th-000.html
word-break/word-break-normal-zh-000.html
</wpt>
<dt><dfn>break-all</dfn></dt>
<dd>Breaking is allowed within “words”:
specifically,
in addition to <a>soft wrap opportunities</a> allowed for ''word-break/normal'',
any <a>typographic letter units</a>
(and any <a>typographic character units</a> resolving to the
<code>NU</code> (“numeric”), <code>AL</code> (“alphabetic”), or <code>SA</code> (“Southeast Asian”)
line breaking classes [[!UAX14]])
are instead treated as <code>ID</code> (“ideographic characters”)
for the purpose of line-breaking.
Hyphenation is not applied.
<wpt>
word-break/word-break-break-all-000.html
word-break/word-break-break-all-001.html
word-break/word-break-break-all-002.html
word-break/word-break-break-all-003.html
word-break/word-break-break-all-005.html
word-break/word-break-break-all-006.html
word-break/word-break-break-all-012.html
word-break/word-break-break-all-013.html
word-break/word-break-break-all-014.html
word-break/word-break-break-all-015.html
word-break/word-break-break-all-016.html
word-break/word-break-break-all-017.html
word-break/word-break-break-all-018.html
word-break/word-break-break-all-019.html
word-break/word-break-break-all-020.html
word-break/word-break-break-all-021.html
word-break/word-break-break-all-022.html
word-break/word-break-break-all-023.html
word-break/word-break-break-all-024.html
word-break/word-break-break-all-025.html
word-break/word-break-break-all-026.html
word-break/word-break-break-all-027.html
word-break/word-break-break-all-028.html
word-break/word-break-break-all-029.html
word-break/word-break-break-all-030.html
word-break/word-break-break-all-inline-001.html
word-break/word-break-break-all-inline-002.html
word-break/word-break-break-all-inline-003.html
word-break/word-break-break-all-inline-004.html
word-break/word-break-break-all-inline-005.html
word-break/word-break-break-all-inline-006.html
word-break/word-break-break-all-inline-007.html
word-break/word-break-break-all-inline-008.html
word-break/word-break-break-all-inline-009.html
word-break/word-break-break-all-inline-010.html
white-space/break-spaces-006.html
white-space/break-spaces-008.html
white-space/break-spaces-before-first-char-004.html
white-space/break-spaces-before-first-char-005.html
white-space/break-spaces-before-first-char-006.html
overflow-wrap/overflow-wrap-anywhere-006.html
line-break/line-break-loose-hyphens-002.html
line-break/line-break-normal-hyphens-002.html
line-break/line-break-strict-hyphens-002.html
</wpt>
Note: This value does not affect
whether there are <a>soft wrap opportunities</a>
around punctuation characters.
To allow breaks anywhere, see ''line-break: anywhere''.
<wpt>
white-space/break-spaces-before-first-char-011.html
</wpt>
Note: This option enables the other common behavior for Ethiopic.
It is also often used in a context where
the text consists predominantly of CJK characters
with only short non-CJK excerpts,
and it is desired that the text be better distributed on each line.
<dt><dfn>keep-all</dfn></dt>
<dd>Breaking is forbidden within “words”:
implicit <a>soft wrap opportunities</a> between <a>typographic letter units</a>
(or other <a>typographic character units</a>
belonging to the
<code>NU</code>, <code>AL</code>, <code>AI</code>, or <code>ID</code>
Unicode line breaking classes [[!UAX14]])
are suppressed,
i.e. breaks are prohibited between pairs of such characters
(regardless of 'line-break' settings other than ''line-break/anywhere'')
except where opportunities exist due to dictionary-based breaking.
Otherwise this option is equivalent to ''word-break/normal''.
In this style, sequences of CJK characters do not break.
<wpt>
word-break/word-break-keep-all-000.html
word-break/word-break-keep-all-001.html
word-break/word-break-keep-all-002.html
word-break/word-break-keep-all-003.html
</wpt>
<p class=note>Note: This is the other common behavior for Korean (which uses [=spaces=] between words),
and is also useful for mixed-script text where CJK snippets are mixed
into another language that uses [=spaces=] for separation.
</dl>
<p>Symbols that line-break the same way as letters of a particular category
are affected the same way as those letters.
<div class="example">
<p>Here's a mixed-script sample text:
<pre style="white-space: pre-wrap">
这是一些汉字 and some Latin <bdi dir=rtl>و کمی خط عربی</bdi> และตัวอย่างการเขียนภาษาไทย በጽሑፍ፡ማራዘሙን፡አንዳንድ፡
</pre>
<p>The break-points are determined as follows (indicated by &lsquo;&middot;&rsquo;):
<dl>
<dt>''word-break: normal''</dt>
<dd>
<pre style="white-space: pre-wrap">
这·是·一·些·汉·字·and·some·Latin·<bdi dir=rtl>و·کمی·خط·عربی</bdi>·และ·ตัวอย่าง·การเขียน·ภาษาไทย·በጽሑፍ፡·ማራዘሙን፡·አንዳንድ፡
</pre>
<dt>''word-break: break-all''</dt>
<dd>
<pre style="white-space: pre-wrap">
这·是·一·些·汉·字·a·n·d·s·o·m·e·L·a·t·i·n·<bdi dir=rtl>و·ﮐ·ﻤ·ﻰ·ﺧ·ﻁ·ﻋ·ﺮ·ﺑ·ﻰ</bdi>·แ·ล·ะ·ตั·ว·อ·ย่·า·ง·ก·า·ร·เ·ขี·ย·น·ภ·า·ษ·า·ไ·ท·ย·በ·ጽ·ሑ·ፍ፡·ማ·ራ·ዘ·ሙ·ን፡·አ·ን·ዳ·ን·ድ፡
</pre>
<dt>''word-break: keep-all''</dt>
<dd>
<pre style="white-space: pre-wrap">
这是一些汉字·and·some·Latin·<bdi dir=rtl>و·کمی·خط·عربی</bdi>·และ·ตัวอย่าง·การเขียน·ภาษาไทย·በጽሑፍ፡·ማራዘሙን፡·አንዳንድ፡
</pre>
</dl>
</div>
<div class="example" id=jp-title-break>
<style>
#jp-title-break td samp,
#jp-title-break td pre {
font-size: 1.5em;
width: 9em;
line-height: 2;
padding: 0.5em 1em;
display: block;
margin: auto;
border: solid gray 1px;
background: white;
}
</style>
<p>Japanese is usually typeset allowing line breaks within words.
However, it is sometimes preferred to suppress these wrapping opportunities
and to only allow wrapping at the end of certain sentence fragments.
This is most commonly done in very short pieces of text,
such as headings and table or figure captions.
This can be achieved by marking the allowed wrapping points
with <{wbr}> or U+200B ZERO WIDTH SPACE,
and suppressing the other ones using ''word-break: keep-all''.
For instance, the following markup can produce either of the renderings below,
depending on the value of the 'word-break' property:
<pre><code highlight=markup>
&lt;h1>窓ぎわの&lt;wbr>トットちゃん&lt;/h1>
</code></pre>
<table class=data>
<colgroup span=1></colgroup>
<colgroup span=2></colgroup>
<thead>
<tr>
<td>
<th><code highlight=css>h1 { word-break: normal }</code>
<th><code highlight=css>h1 { word-break: keep-all }</code>
<tbody>
<tr>
<th scope=row>Expected rendering
<td>
<pre lang=ja>
窓ぎわのトットちゃ
</pre>
<td>
<pre lang=ja>
窓ぎわの
トットちゃん</pre>
<tr>
<th scope=row>Result in your browser
<td>
<samp lang=ja>
窓ぎわの<wbr>トットちゃん
</samp>
<td>
<samp style="word-break:keep-all" lang=ja>
窓ぎわの<wbr>トットちゃん
</samp>
</table>
</div>
<p>When shaping scripts such as Arabic
are allowed to break within words due to ''word-break/break-all''
the characters must still be shaped
as if the word were <a href="#word-break-shaping">not broken</a>
(see [[#word-break-shaping]]).
<wpt>
word-break/word-break-break-all-004.html
</wpt>
<p>For compatibility with legacy content,
the 'word-break' property also supports a deprecated <dfn value for=word-break>break-word</dfn> keyword.
When specified, this has the same effect as
''word-break: normal'' and ''overflow-wrap: anywhere'',
regardless of the actual value of the 'overflow-wrap' property.
<!-- This is officially sad -->
<wpt>
white-space/pre-wrap-008.html
white-space/pre-wrap-016.html
word-break/word-break-break-word-overflow-wrap-interactions.html
word-break/word-break-break-word-crash-001.html
white-space/break-spaces-003.html
white-space/break-spaces-004.html
white-space/break-spaces-008.html
white-space/break-spaces-before-first-char-010.html
word-break/word-break-min-content-001.html
word-break/word-break-min-content-002.html
word-break/word-break-min-content-003.html
word-break/word-break-min-content-004.html
word-break/word-break-min-content-005.html
word-break/word-break-min-content-006.html
</wpt>
<h3 id="line-break-property">
Line Breaking Strictness: the 'line-break' property</h3>
<pre class="propdef">
Name: line-break
Value: auto | loose | normal | strict | anywhere
Initial: auto
Applies to: <a>inline boxes</a>
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
</pre>
<wpt>
inheritance.html
parsing/line-break-valid.html
parsing/line-break-invalid.html
parsing/line-break-computed.html
</wpt>
<p>This property specifies the strictness of line-breaking rules applied
within an element:
especially how <a>wrapping</a> interacts with punctuation and symbols.
Values have the following meanings:</p>
<dl dfn-for=line-break dfn-type=value>
<dt><dfn>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.
<dt><dfn>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>normal</dfn></dt>
<dd>Breaks text using the most common set of line-breaking rules.</dd>
<dt><dfn>strict</dfn></dt>
<dd>Breaks text using the most stringent set of line-breaking
rules.</dd>
<dt><dfn>anywhere</dfn></dt>
<dd>There is a <a>soft wrap opportunity</a> around every <a>typographic character unit</a>,
including around any punctuation character or [=preserved white spaces=],
or in the middle of words,
disregarding any prohibition against line breaks,
even those introduced by characters with the GL, WJ, or ZWJ character class (see [[UAX14]])
or mandated by the 'word-break' property.
The different wrapping opportunities must not be prioritized.
Hyphenation is not applied.
<wpt>
line-break/line-break-anywhere-001.html
line-break/line-break-anywhere-002.html
line-break/line-break-anywhere-003.html
line-break/line-break-anywhere-004.html
line-break/line-break-anywhere-005.html
line-break/line-break-anywhere-006.html
line-break/line-break-anywhere-007.html
line-break/line-break-anywhere-008.html
line-break/line-break-anywhere-009.html
line-break/line-break-anywhere-010.html
line-break/line-break-anywhere-011.html
line-break/line-break-anywhere-012.html
line-break/line-break-anywhere-013.html
line-break/line-break-anywhere-014.html
line-break/line-break-anywhere-015.html
line-break/line-break-anywhere-016.html
line-break/line-break-anywhere-017.html
line-break/line-break-anywhere-and-white-space-001.html
line-break/line-break-anywhere-and-white-space-002.html
line-break/line-break-anywhere-and-white-space-003.html
line-break/line-break-anywhere-and-white-space-004.html
line-break/line-break-anywhere-and-white-space-005.html
line-break/line-break-anywhere-and-white-space-006.html
line-break/line-break-anywhere-and-white-space-007.html
line-break/line-break-anywhere-and-white-space-008.html
line-break/line-break-anywhere-and-white-space-009.html
line-break/line-break-anywhere-and-white-space-009.html
line-break/line-break-anywhere-overrides-uax-behavior-001.html
line-break/line-break-anywhere-overrides-uax-behavior-002.html
line-break/line-break-anywhere-overrides-uax-behavior-003.html
line-break/line-break-anywhere-overrides-uax-behavior-004.html
line-break/line-break-anywhere-overrides-uax-behavior-005.html
line-break/line-break-anywhere-overrides-uax-behavior-006.html
line-break/line-break-anywhere-overrides-uax-behavior-007.html
line-break/line-break-anywhere-overrides-uax-behavior-008.html
line-break/line-break-anywhere-overrides-uax-behavior-009.html
line-break/line-break-anywhere-overrides-uax-behavior-010.html
line-break/line-break-anywhere-overrides-uax-behavior-011.html
line-break/line-break-anywhere-overrides-uax-behavior-012.html
line-break/line-break-anywhere-overrides-uax-behavior-013.html
line-break/line-break-anywhere-overrides-uax-behavior-014.html
line-break/line-break-anywhere-overrides-uax-behavior-015.html
line-break/line-break-anywhere-overrides-uax-behavior-016.html
line-break/line-break-shaping-001.html
white-space/break-spaces-before-first-char-007.html
white-space/break-spaces-before-first-char-011.html
</wpt>
Note: This value triggers the line breaking rules typically seen in terminals.</dd>
<div class=note>
Note: ''line-break/anywhere'' only allows [=preserved white spaces=] at the end of the line
to be wrapped to the next line when 'white-space' is set to ''white-space/break-spaces'',
because in other cases:
* [=preserved white space=] at the end/start of the line is discarded (''white-space/normal'', ''white-space/pre-line'')
* wrapping is forbidden altoghether (''nowrap'', ''pre'')
* the [=preserved white space=] [=hang=] (''pre-wrap'').
When it does have an effect on [=preserved white space=],
with ''white-space: break-spaces'',
it allows breaking before the first space of a sequence,
which ''break-spaces'' on its own does not.
</div>
<wpt>
line-break/line-break-anywhere-005.html
white-space/break-spaces-before-first-char-007.html
white-space/break-spaces-before-first-char-008.html
white-space/break-spaces-before-first-char-009.html
white-space/break-spaces-before-first-char-010.html
</wpt>
</dl>
<p class="feedback issue">
The rules here are following guidelines from <a href="https://www.w3.org/TR/klreq/#line-break">KLREQ</a> for Korean,
which don't allow the Chinese/Japanese-specific breaks.
However, the resulting behavior could use some review and feedback to make sure they are correct,
particularly when “word basis” breaking is used (''word-break: keep-all'') in Korean.
<p>CSS distinguishes between four levels of strictness in the rules for
text wrapping.
The precise set of rules in effect for each of ''line-break/loose'', ''line-break/normal'', and ''line-break/strict'' is up to the UA
and should follow language conventions.
However, this specification does require that:</p>
<ul>
<li>
The following breaks are forbidden in ''strict'' line breaking
and allowed in ''line-break/normal'' and ''loose'':
<ul>
<li>breaks before Japanese small kana or the Katakana-Hiragana prolonged sound mark,
i.e. character from the Unicode line breaking class <code>CJ</code> [[!UAX14]].
<wpt>
line-break/line-break-loose-011.xht
line-break/line-break-loose-012.xht
line-break/line-break-normal-011.xht
line-break/line-break-normal-012.xht
line-break/line-break-strict-011.xht
line-break/line-break-strict-012.xht
i18n/ja/css-text-line-break-ja-cj-loose.html
i18n/ja/css-text-line-break-ja-cj-normal.html
i18n/ja/css-text-line-break-ja-cj-strict.html
i18n/zh/css-text-line-break-zh-cj-loose.html
i18n/zh/css-text-line-break-zh-cj-normal.html
i18n/zh/css-text-line-break-zh-cj-strict.html
i18n/other-lang/css-text-line-break-de-cj-loose.html
i18n/other-lang/css-text-line-break-de-cj-normal.html
i18n/other-lang/css-text-line-break-de-cj-strict.html
i18n/unknown-lang/css-text-line-break-cj-loose.html
i18n/unknown-lang/css-text-line-break-cj-normal.html
i18n/unknown-lang/css-text-line-break-cj-strict.html
</wpt>
</ul>
<li>
The following breaks are allowed for ''line-break/normal'' and ''loose'' line breaking
if the <a>writing system</a> is <a for=writing-system>Chinese</a> or <a for=writing-system>Japanese</a>,
and are otherwise forbidden:
<ul>
<li>breaks before certain CJK hyphen-like characters:<br>
&#x301C;&nbsp;U+301C,
&#x30A0;&nbsp;U+30A0
<wpt>
line-break/line-break-loose-013.xht
line-break/line-break-normal-013.xht
line-break/line-break-strict-013.xht
i18n/ja/css-text-line-break-ja-hyphens-loose.html
i18n/ja/css-text-line-break-ja-hyphens-normal.html
i18n/ja/css-text-line-break-ja-hyphens-strict.html
i18n/zh/css-text-line-break-zh-hyphens-loose.html
i18n/zh/css-text-line-break-zh-hyphens-normal.html
i18n/zh/css-text-line-break-zh-hyphens-strict.html
i18n/other-lang/css-text-line-break-de-hyphens-loose.html
i18n/other-lang/css-text-line-break-de-hyphens-normal.html
i18n/other-lang/css-text-line-break-de-hyphens-strict.html
i18n/unknown-lang/css-text-line-break-hyphens-loose.html
i18n/unknown-lang/css-text-line-break-hyphens-normal.html
i18n/unknown-lang/css-text-line-break-hyphens-strict.html
writing-system/writing-system-line-break-001.html
</wpt>
</ul>
<li>
The following breaks are allowed for ''loose'' line breaking
if the preceding character belongs to the Unicode line breaking class <code>ID</code> [[!UAX14]]
(including when the preceding character is treated as <code>ID</code> due to ''word-break: break-all''),
and are otherwise forbidden:
<ul>
<li>breaks before hyphens:<br>
&#x2010;&nbsp;U+2010, &#x2013;&nbsp;U+2013
<wpt>
line-break/line-break-loose-hyphens-001.html
line-break/line-break-normal-hyphens-001.html
line-break/line-break-strict-hyphens-001.html
line-break/line-break-loose-hyphens-002.html
line-break/line-break-normal-hyphens-002.html
line-break/line-break-strict-hyphens-002.html
line-break/line-break-loose-hyphens-003.html
line-break/line-break-normal-hyphens-003.html
line-break/line-break-strict-hyphens-003.html
</wpt>
</ul>
<li>
The following breaks are forbidden for ''line-break/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
<wpt>
line-break/line-break-loose-014.xht
line-break/line-break-normal-014.xht
line-break/line-break-strict-014.xht
i18n/ja/css-text-line-break-ja-iteration-loose.html
i18n/ja/css-text-line-break-ja-iteration-normal.html
i18n/ja/css-text-line-break-ja-iteration-strict.html
i18n/zh/css-text-line-break-zh-iteration-loose.html
i18n/zh/css-text-line-break-zh-iteration-normal.html
i18n/zh/css-text-line-break-zh-iteration-strict.html
i18n/other-lang/css-text-line-break-de-iteration-loose.html
i18n/other-lang/css-text-line-break-de-iteration-normal.html
i18n/other-lang/css-text-line-break-de-iteration-strict.html
i18n/unknown-lang/css-text-line-break-iteration-loose.html
i18n/unknown-lang/css-text-line-break-iteration-normal.html
i18n/unknown-lang/css-text-line-break-iteration-strict.html
</wpt>
<li>breaks between inseparable characters
(such as &#x2025;&nbsp;U+2025, &#x2026;&nbsp;U+2026)
i.e. characters from the Unicode line breaking class <code>IN</code> [[!UAX14]].
<wpt>
line-break/line-break-loose-015.xht
line-break/line-break-normal-015a.xht
line-break/line-break-normal-015b.xht
line-break/line-break-strict-015a.xht
line-break/line-break-strict-015b.xht
i18n/ja/css-text-line-break-ja-in-loose.html
i18n/ja/css-text-line-break-ja-in-normal.html
i18n/ja/css-text-line-break-ja-in-strict.html
i18n/zh/css-text-line-break-zh-in-loose.html
i18n/zh/css-text-line-break-zh-in-normal.html
i18n/zh/css-text-line-break-zh-in-strict.html
i18n/other-lang/css-text-line-break-de-in-loose.html
i18n/other-lang/css-text-line-break-de-in-normal.html
i18n/other-lang/css-text-line-break-de-in-strict.html
i18n/unknown-lang/css-text-line-break-in-loose.html
i18n/unknown-lang/css-text-line-break-in-normal.html
i18n/unknown-lang/css-text-line-break-in-strict.html
</wpt>
</ul>
<li>
The following breaks are allowed for ''loose''
if the <a>writing system</a> is <a for=writing-system>Chinese</a> or <a for=writing-system>Japanese</a>
and are otherwise forbidden:
<ul>
<li>breaks before certain centered punctuation marks:<br>
&#x30FB;&nbsp;U+30FB,
&#xFF1A;&nbsp;U+FF1A, &#xFF1B;&nbsp;U+FF1B, &#xFF65;&nbsp;U+FF65,
&#x203C;&nbsp;U+203C,
&#x2047;&nbsp;U+2047, &#x2048;&nbsp;U+2048, &#x2049;&nbsp;U+2049,
&#xFF01;&nbsp;U+FF01, &#xFF1F;&nbsp;U+FF1F
<wpt>
line-break/line-break-loose-016a.xht
line-break/line-break-loose-016b.xht
line-break/line-break-normal-016a.xht
line-break/line-break-normal-016b.xht
line-break/line-break-strict-016a.xht
line-break/line-break-strict-016b.xht
i18n/ja/css-text-line-break-ja-cpm-loose.html
i18n/ja/css-text-line-break-ja-cpm-normal.html
i18n/ja/css-text-line-break-ja-cpm-strict.html
i18n/zh/css-text-line-break-zh-cpm-loose.html
i18n/zh/css-text-line-break-zh-cpm-normal.html
i18n/zh/css-text-line-break-zh-cpm-strict.html
i18n/other-lang/css-text-line-break-de-cpm-loose.html
i18n/other-lang/css-text-line-break-de-cpm-normal.html
i18n/other-lang/css-text-line-break-de-cpm-strict.html
i18n/unknown-lang/css-text-line-break-cpm-loose.html
i18n/unknown-lang/css-text-line-break-cpm-normal.html
i18n/unknown-lang/css-text-line-break-cpm-strict.html
writing-system/writing-system-line-break-002.html
</wpt>
<li>breaks before suffixes:<br>
Characters with the Unicode line breaking class <code>PO</code> [[!UAX14]]
and the <a>East Asian Width property</a> [[!UAX11]]
<code>Ambiguous</code>, <code>Fullwidth</code>, or <code>Wide</code>.
<wpt>
line-break/line-break-loose-017a.xht
line-break/line-break-loose-017b.xht
line-break/line-break-normal-017a.xht
line-break/line-break-normal-017b.xht
line-break/line-break-strict-017a.xht
line-break/line-break-strict-017b.xht
i18n/ja/css-text-line-break-ja-po-loose.html
i18n/ja/css-text-line-break-ja-po-normal.html
i18n/ja/css-text-line-break-ja-po-strict.html
i18n/zh/css-text-line-break-zh-po-loose.html
i18n/zh/css-text-line-break-zh-po-normal.html
i18n/zh/css-text-line-break-zh-po-strict.html
i18n/other-lang/css-text-line-break-de-po-loose.html
i18n/other-lang/css-text-line-break-de-po-normal.html
i18n/other-lang/css-text-line-break-de-po-strict.html
i18n/unknown-lang/css-text-line-break-po-loose.html
i18n/unknown-lang/css-text-line-break-po-normal.html
i18n/unknown-lang/css-text-line-break-po-strict.html
</wpt>
<li>breaks after prefixes:<br>
Characters with the Unicode line breaking class <code>PR</code> [[!UAX14]]
and the <a>East Asian Width property</a> [[!UAX11]]
<code>Ambiguous</code>, <code>Fullwidth</code>, or <code>Wide</code>.
<wpt>
line-break/line-break-loose-018.xht
line-break/line-break-normal-018.xht
line-break/line-break-strict-018.xht
i18n/ja/css-text-line-break-ja-pr-loose.html
i18n/ja/css-text-line-break-ja-pr-normal.html
i18n/ja/css-text-line-break-ja-pr-strict.html
i18n/zh/css-text-line-break-zh-pr-loose.html
i18n/zh/css-text-line-break-zh-pr-normal.html
i18n/zh/css-text-line-break-zh-pr-strict.html
i18n/other-lang/css-text-line-break-de-pr-loose.html
i18n/other-lang/css-text-line-break-de-pr-normal.html
i18n/other-lang/css-text-line-break-de-pr-strict.html
i18n/unknown-lang/css-text-line-break-pr-loose.html
i18n/unknown-lang/css-text-line-break-pr-normal.html
i18n/unknown-lang/css-text-line-break-pr-strict.html
</wpt>
</ul>
</ul>
<p class="note">Note:
The requirements listed above
only create distinctions in CJK text.
In an implementation that matches only the rules above,
and no additional rules,
'line-break' would only affect CJK code points
unless the writing system is tagged as
<a for=writing-system>Chinese</a> or <a for=writing-system>Japanese</a>.
Future levels may add additional specific rules
for other writing systems and languages
as their requirements become known.
<div class="example">
As UAs can add additional distinctions
between ''line-break/strict''/''line-break/normal''/''line-break/loose'' modes,
these values can exhibit differences in other writing systems as well.
For example, a UA with sufficiently-advanced Thai language processing ability
could choose to map different levels of strictness in Thai line-breaking
to these keywords,
e.g. disallowing breaks within compound words in ''line-break/strict'' mode
(e.g. breaking ตัวอย่างการเขียนภาษาไทย as ตัวอย่าง·การเขียน·ภาษาไทย)
while allowing more breaks in ''line-break/loose''
(ตัวอย่าง·การ·เขียน·ภาษา·ไทย).
</div>