Title: CSS Text Module Level 3
Shortname: css-text
Level: 3
Status: ED
Work Status: Testing
Group: csswg
ED: https://drafts.csswg.org/css-text-3/
TR: https://www.w3.org/TR/css-text-3/
Previous version: https://www.w3.org/TR/2023/CRD-css-text-3-20230903/
Test Suite: http://test.csswg.org/suites/css3-text/nightly-unstable/
!Test Coverage Analysis: https://drafts.csswg.org/css-text-3/test-coverage
Implementation Report: https://test.csswg.org/harness/results/css-text-3_dev/grouped/
Editor: Elika J. Etemad / fantasai, Apple, http://fantasai.inkedblade.net/contact, w3cid 35400
Editor: Koji Ishii, Invited Expert, 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 <length> values of the 'tab-size' property
At Risk: the 'text-justify' property
At Risk: the 'hanging-punctuation' property
At Risk: Writing-system specific adjustments to line-breaking
At Risk: Trimming trailing Ogham space marks
Ignored Vars: letter-spacing
WPT Path Prefix: /css/css-text/
spec:css2; type:dfn; text:document language
spec:css-ruby-1; type:dfn; text:ruby
Introduction
This module describes the typesetting controls of CSS;
that is, the features of CSS that control the translation of
source text to formatted, line-wrapped text.
Various CSS properties provide control over
[[#transforming|case transformation]],
[[#white-space-processing|white space collapsing]],
[[#white-space-property|text wrapping]],
[[#line-breaking|line breaking rules]]
and [[#hyphenation|hyphenation]],
[[#justification|alignment and justification]],
[[#spacing|spacing]],
and [[#edge-effects|indentation]].
Note: Font selection is covered in the CSS Fonts Module.
[[CSS-FONTS-3]]
Features for decorating text,
such as [[css-text-decor-3#line-decoration|underlines]],
[[css-text-decor-3#emphasis-marks|emphasis marks]],
and [[css-text-decor-3#text-shadow-property|shadows]],
(previously part of this module)
are covered in the
CSS Text Decoration Module.
[[CSS-TEXT-DECOR-3]]
[[css-writing-modes-4#text-direction|Bidirectional]] and
[[css-writing-modes-4#vertical-intro|vertical]] text
are addressed in the
CSS Writing Modes Module.
[[CSS-WRITING-MODES-4]].
Further information about the typesetting requirements
of various languages and writing systems around the world
can be found in the Internationalization Working Group’s
Language Enablement Index.
[[TYPOGRAPHY]]
removing-collapsible-crash.html
removing-collapsible-spaces-before-float-crash.html
crashtests/line-break-float-crash.html
crashtests/trailing-space-with-cr-crash.html
ellisize-rtl-text-crash.html
altering-dom-crash.html
whitespace-followed-by-cham-symbol-crash.html
white-space/append-whitespace-only-node-crash-001.html
crashtests/rendering-rtl-bidi-override-crash.html
crashtests/rendering-table-caption-with-list-item-and-svg-crash.html
crashtests/rendering-table-caption-with-negative-margins-crash.html
crashtests/white-space-pre-wrap-chash.html
crashtests/word-spacing-large-value.html
crashtests/eol-spaces-bidi-min-content-crash.html
crashtests/overflow-wrap-anywhere-crash.html
crashtests/text-indent-each-line-crash.html
overflow-wrap/crashtests/overflow-wrap-leading-floats-crash.html
text-autospace/crashtests/text-autospace-shape-cache-crash.html
text-indent/text-indent-ruby-crash.html
This specification follows the [[CSS2/about#property-defs|CSS property definition conventions]] from [[!CSS2]]
using the [[css-values-3#value-defs|value definition syntax]] from [[!CSS-VALUES-3]].
Value types not defined in this specification are defined in CSS Values & Units [[!CSS-VALUES-3]].
Combination with other CSS modules may expand the definitions of these value types.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification
also accept the [=CSS-wide keywords=] as their property value.
For readability they have not been repeated explicitly.
Languages and Typesetting
Authors should accurately language-tag their content
for the best typographic behavior.
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.
In CSS, language-specific typographic tailorings
are only applied when the [=content language=] is known (declared).
Therefore,
higher quality typography requires authors to communicate to the UA
the correct linguistic context of the text in the document.
The content language of an element is the (human) language
the element is declared to be in, according to the rules of the
[=document language=].
Note that it is possible for the [=content language=] of an element
to be unknown--
e.g. untagged content,
or content in a [=document language=] that does not have a language-tagging facility,
is considered to have an unknown [=content language=].
Note: Authors can declare the [=content language=]
using the global lang attribute in HTML
or the universal xml:lang attribute in XML.
See the rules for determining the content language of an HTML element
in HTML,
and the [[XML#sec-lang-tag|rules for determining the content language of an XML element]] in XML 1.0.
[[HTML]]
[[XML10]]
The [=content language=] an element is declared to be in
also identifies the specific written form of that language used in that element,
known as the content writing system.
Depending on the [=document language=]’s facilities for identifying the [=content language=],
this information can be explicit or implied.
See the normative [[#script-tagging]].
Note: Some languages have more than one writing system tradition;
in other cases a language can be transliterated into a foreign writing system.
Authors should [[#script-tagging|subtag]] such cases
so that the UA can adapt appropriately.
For example, Korean (ko) can be written in
Hangul (-Hang),
Hanja (-Hani),
or a combination (-Kore).
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 ko-Hani
behaves more like zh-Hant
than ko (ko-Kore).
As another example Japanese (ja) is typically written
in a combination (-Japn) of Hiragana (-Hira),
Katakana (-Kana), and Kanji (-Hani).
However, it can also be “romanized” into Latin (-Latn)
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 (-Cyrl, officially used in Mongolia)
and Mongolian (-Mong, 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.
Characters and Letters
The basic unit of typesetting is the character.
However, because writing systems are not always as simple as the basic English alphabet,
what a [=character=] actually is depends on the context in which the term is used.
For example, in Hangul (the Korean writing system),
each square representation of a syllable
(e.g. 한=Han)
can be considered a character.
However, the square symbol is really composed of multiple letters each representing a phoneme
(e.g. ㅎ=h,
ㅏ=a,
ㄴ=n)
and these also could each be considered a character.
A basic unit of computer text encoding, for any given encoding,
is also called a [=character=],
and depending on the encoding,
a single encoding [=character=] might correspond
to the entire pre-composed syllabic [=character=] (e.g. 한),
to the individual phonemic [=character=] (e.g. ㅎ),
or to smaller units such as
a base letterform (e.g. ㅇ)
and any combining marks that vary it (e.g. extra strokes that represent aspiration).
In turn, a single encoding [=character=] can be represented in the data stream as one or more bytes;
and in programming environments one byte is sometimes also called a [=character=].
Therefore the term [=character=] is fairly ambiguous where technical precision is required.
For text layout, we will refer to the typographic character unit
as the basic unit of text.
Even within the realm of text layout,
the relevant [=character=] unit depends on the operation.
For example, line-breaking and letter-spacing will segment
a sequence of Thai characters that include U+0E33 ำ THAI CHARACTER SARA AM differently;
or the behavior of a conjunct consonant in a script such as Devanagari
may depend on the font in use.
So the [=typographic character=] represents a unit of the writing system--
such as a Latin alphabetic letter (including its diacritics),
Hangul syllable,
Chinese ideographic character,
Myanmar syllable cluster--
that is indivisible with respect to a particular typographic operation
(line-breaking, first-letter effects, tracking, justification, vertical arrangement, etc.).
word-break/word-break-break-all-007.html
word-break/word-break-break-all-008.html
Unicode Standard Annex #29: Text Segmentation
defines a unit called the grapheme cluster
which approximates the [=typographic character=].
[[!UAX29]]
A UA must use the extended grapheme cluster
(not legacy grapheme cluster), as defined in UAX29,
as the basis for its [=typographic character unit=].
However, the UA should tailor the definitions
as required by typographic tradition
since the default rules are not always appropriate or ideal--
and is expected to tailor them differently
depending on the operation as needed.
line-breaking/line-breaking-013.html
line-breaking/line-breaking-014.html
Note: The rules for such tailorings are out of scope for CSS.
The following are some examples of [=typographic character unit=] tailorings
required by standard typesetting practice:
In some scripts such as Myanmar or Devanagari,
the [=typographic character unit=] for both justification and line-breaking
is an entire syllable,
which can include more than one Unicode [=grapheme cluster=].
[[!UAX29]]
In other scripts such as Thai or Lao,
even though for line-breaking the [=typographic character=]
matches Unicode’s default [=grapheme clusters=],
for letter-spacing the relevant unit
is less than a Unicode [=grapheme cluster=],
and may require decomposition or other substitutions
before spacing can be inserted.
[[!UAX29]]
For instance,
to properly letter-space the Thai word คำ (U+0E04 + U+0E33),
the U+0E33 needs to be decomposed into U+0E4D + U+0E32,
and then the extra letter-space inserted before the U+0E32: คํ า.
A slightly more complex example is น้ำ (U+0E19 + U+0E49 + U+0E33).
In this case, normal Thai shaping will first decompose the U+0E33 into U+0E4D + U+0E32
and then swap the U+0E4D with the U+0E49, giving U+0E19 + U+0E4D + U+0E49 + U+0E32.
As before the extra letter-space is then inserted before the U+0E32: นํ้ า.
Vertical typesetting can also require tailoring.
For example, when typesetting ''text-orientation/upright'' text,
Tibetan tsek and shad marks are kept with the preceding grapheme cluster,
rather than treated as an independent [=typographic character unit=].
[[!CSS-WRITING-MODES-4]]
A typographic letter unit
(or letter for the purpose of this specification)
is a [=typographic character unit=] belonging to one of the Letter or Number
[=general categories=].
See [[#character-properties]]
for how to determine the Unicode properties of a [=typographic character unit=].
The rendering characteristics of a [=typographic character unit=] divided
by an element boundary is undefined.
Ideally each component should be rendered
according to the formatting requirements of its respective element’s properties
while maintaining correct shaping and positioning
of the [=typographic character unit=] as a whole.
However, depending on the nature of the formatting differences between its parts
and the capabilities of the font technology in use,
this is not always possible.
Therefore such a [=typographic character unit=]
may be rendered as belonging to either side of the boundary,
or as some approximation of belonging to both.
Authors are forewarned that dividing [=grapheme clusters=]
or ligatures
by element boundaries may give inconsistent or undesired results.
Text Processing
CSS is built on Unicode.
[[UNICODE]]
UAs that support Unicode must adhere to all normative requirements
of the Unicode Core Standard,
except where explicitly overridden by CSS.
UAs implemented on the basis of a non-Unicode text encoding model are still
expected to fulfill the same text handling requirements
by assuming an appropriate mapping and analogous behavior.
text-encoding/shaping-join-001.html
text-encoding/shaping-join-002.html
text-encoding/shaping-join-003.html
text-encoding/shaping-no-join-001.html
text-encoding/shaping-no-join-002.html
text-encoding/shaping-no-join-003.html
text-encoding/shaping-tatweel-001.html
text-encoding/shaping-tatweel-002.html
text-encoding/shaping-tatweel-003.html
shaping/shaping-arabic-diacritics-001.html
shaping/shaping-arabic-diacritics-002.html
white-space/full-width-leading-spaces-005.html
white-space/object-replacement-1.html
white-space/object-replacement-2.html
white-space/white-space-vs-joiners-001.html
white-space/white-space-vs-joiners-002.html
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]].
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
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
white-space-processing-048.xht
white-space-processing-049.xht
inheritance.html
parsing/text-transform-valid.html
parsing/text-transform-invalid.html
parsing/text-transform-computed.html
text-transform/text-transform-multiple-001.html
c545-txttrans-000.xht
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
This property transforms text for styling purposes.
It has no effect on the underlying content,
and must not affect the content of a plain text copy & paste operation.
text-transform/text-transform-upperlower-105.html
Advisement: Authors must not rely on 'text-transform' for semantic purposes;
rather the correct casing and semantics should be encoded
in the source document text and markup.
text-transform/text-transform-copy-paste-001-manual.html
Values have the following meanings:
none
No effects.
text-transform/text-transform-none-001.xht
text-transform-004.xht
capitalize
Puts the first [=typographic letter unit=] of each word, if lowercase, in titlecase;
other characters are unaffected.
text-transform/text-transform-capitalize-001.html
text-transform/text-transform-capitalize-003.html
text-transform/text-transform-capitalize-005.html
text-transform/text-transform-capitalize-007.html
text-transform/text-transform-capitalize-009.html
text-transform/text-transform-capitalize-010.html
text-transform/text-transform-capitalize-011.html
text-transform/text-transform-capitalize-014.html
text-transform/text-transform-capitalize-016.html
text-transform/text-transform-capitalize-018.html
text-transform/text-transform-capitalize-020.html
text-transform/text-transform-capitalize-022.html
text-transform/text-transform-capitalize-024.html
text-transform/text-transform-capitalize-026.html
text-transform/text-transform-capitalize-028.html
text-transform/text-transform-capitalize-030.html
text-transform/text-transform-capitalize-031.html
text-transform/text-transform-capitalize-032.xht
text-transform/text-transform-capitalize-034.html
text-transform/text-transform-capitalize-035.html
text-transform-001.xht
text-transform-cap-001.xht
text-transform-cap-002.xht
text-transform-cap-003.xht
Puts all [=typographic character units=] in [=full-width=] form.
If a character does not have a corresponding [=full-width=] form,
it is left as is.
This value is typically used to typeset Latin letters and digits
as if they were ideographic characters.
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
full-size-kana
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.
text-transform/text-transform-full-size-kana-001.html
text-transform/text-transform-full-size-kana-002.html
text-transform/text-transform-full-size-kana-003.html
text-transform/text-transform-full-size-kana-004.html
text-transform/text-transform-full-size-kana-005.html
text-transform/text-transform-full-size-kana-006.html
text-transform/text-transform-full-size-kana-007.html
text-transform/text-transform-full-size-kana-008.html
The following example converts the ASCII characters
used in abbreviations in Japanese text to their full-width variants
so that they lay out and line break like ideographs:
abbr:lang(ja) { text-transform: full-width; }
Note: The purpose of 'text-transform' is
to allow for presentational casing transformations
without affecting the semantics of the document.
Note in particular that 'text-transform' casing operations are lossy,
and can distort the meaning of a text.
While accessibility interfaces may wish to convey
the apparent casing of the rendered text to the user,
the transformed text cannot be relied on to accurately represent
the underlying meaning of the document.
In this example,
the first line of text is capitalized as a visual effect.
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.
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=].
Note that while this makes such letters easier to see at small type sizes,
the transformation distorts the text:
the reader needs to mentally substitute [=small kana=]
in the appropriate places--
not unlike reading a Latin inscription
where all “U”s look like “V”s.
For example, if ''text-transform: full-size-kana'' were applied to the following source,
the annotation would read “じゆう” (jiyū), which means “liberty”,
instead of “じゅう” (jū), which means “ten”,
the correct reading and meaning for the annotated “十”.
十
Mapping Rules
For ''capitalize'', what constitutes a “word“ is UA-dependent;
[[!UAX29]] is suggested (but not required)
for determining such word boundaries.
Out-of-flow elements and inline element boundaries
must not introduce a 'text-transform' word boundary
and must be ignored when determining such word boundaries.
text-transform/text-transform-capitalize-033.html
text-transform/text-transform-capitalize-034.html
text-transform/text-transform-capitalize-035.html
Note: Authors cannot depend on ''capitalize'' to follow
language-specific titlecasing conventions
(such as skipping articles in English).
The UA must use the full case mappings for Unicode characters,
including any conditional casing rules,
as defined in the Default Case Algorithms section of The Unicode Standard.
[[!UNICODE]]
If (and only if) the [=content language=] of the element is,
according to the rules of the [=document language=],
known,
then any appropriate language-specific rules must be applied as well.
These minimally include,
but are not limited to,
the language-specific rules in Unicode’s
SpecialCasing.txt.
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
For example, in Turkish there are two “i”s,
one with a dot--
“İ” and “i”--
and one without--
“I” and “ı”.
Thus the usual case mappings between “I” and “i”
are replaced with a different set of mappings
to their respective dotless/dotted counterparts,
which do not exist in English.
This mapping must only take effect
if the [=content language=] is Turkish
written in its modern Latin-based [=writing system=]
(or another Turkic language that uses Turkish casing rules);
in other languages,
the usual mapping of “I” and “i” is required.
This rule is thus conditionally defined in Unicode’s SpecialCasing.txt file.
text-transform-bicameral-005.xht
text-transform-bicameral-006.xht
The definition of full-width and half-width forms
can be found in Unicode Standard Annex #11: East Asian Width.
[[!UAX11]]
The mapping to [=full-width=] form is defined
by taking code points with the <wide>
or the <narrow> tag
in their Decomposition_Mapping
in Unicode Standard Annex #44: Unicode Character Database.
[[!UAX44]]
For the <narrow> tag,
the mapping is from the code point to the decomposition
(minus <narrow> tag),
and for the <wide> tag,
the mapping is from the decomposition
(minus the <wide> tag)
back to the original code point.
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
The mappings for [=small Kana=] to [=full-size Kana=] are defined in [[#small-kana]].
Order of Operations
When multiple values are specified
and therefore multiple transformations need to be applied,
they are applied in the following order:
''capitalize'', ''uppercase'', and ''lowercase''
''full-width''
''full-size-kana''
text-transform/text-transform-multiple-001.html
Text transformation happens after [[#white-space-phase-1]]
but before [[#white-space-phase-2]].
This means that ''full-width'' only transforms
spaces (U+0020) to U+3000 IDEOGRAPHIC SPACE within [=preserved=] [=white space=].
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
Note: As defined in [[#order]],
transforming text affects line-breaking and other formatting operations.
White Space and Wrapping: the 'white-space' property
Name: white-space
Value: normal | pre | nowrap | pre-wrap | break-spaces | pre-line
Initial: normal
Applies to: text
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
whether lines may [=wrap=] at unforced [=soft wrap opportunities=]
Values have the following meanings,
which must be interpreted according to
the [[#white-space-rules|White Space Processing]] and
[[#line-breaking|Line Breaking]] rules:
normal
This value directs user agents to collapse sequences of [=white space=]
into a single character
(or [[#line-break-transform|in some cases]], no character).
Lines may wrap at allowed [=soft wrap opportunities=],
as determined by the line-breaking rules in effect,
in order to minimize inline-axis overflow.
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
white-space/white-space-applies-to-text-001.html
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
pre
This value prevents user agents from collapsing sequences of [=white space=].
[=Segment breaks=] such as line feeds
are preserved as [=forced line breaks=].
Lines only break at [=forced line breaks=];
content that does not fit within the block container overflows it.
white-space-pre-001.xht
white-space-pre-002.xht
white-space-pre-005.xht
white-space-pre-006.xht
white-space-pre-007.xht
white-space-pre-element-001.xht
white-space/white-space-zero-fontsize-001.html
white-space/white-space-zero-fontsize-002.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
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
white-space/pre-with-whitespace-crash.html
word-break/break-boundary-2-chars-002.html
white-space/white-space-applies-to-text-001.html
nowrap
Like ''white-space/normal'',
this value collapses [=white space=];
but like ''pre'', it does not allow wrapping.
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
white-space/nowrap-wbr-and-space-crash.html
word-break/break-boundary-2-chars-002.html
white-space/white-space-applies-to-text-001.html
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
The behavior is identical to that of ''white-space/pre-wrap'',
except that:
Any sequence of [=preserved=] [=white space=]
or [=other space separators=]
always takes up space,
including at the end of the line.
white-space/white-space-intrinsic-size-001.html
white-space/white-space-intrinsic-size-002.html
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.
pre-line
Like ''white-space/normal'',
this value collapses consecutive [=white space characters=]
and allows wrapping,
but it preserves [=segment breaks=] in the source as [=forced line breaks=].
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
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
white-space/pre-line-br-with-whitespace-child-crash.html
white-space/pre-line-with-space-and-newline.html
white-space/white-space-applies-to-text-001.html
[=White space=] that was not removed or collapsed due to white space processing
is called preserved white space.
Note: In some cases,
[=preserved white space=] and [=other space separators=]
can [=hang=] when at the end of the line;
this can affect whether they are measured for [=intrinsic sizing=].
The following informative table summarizes the behavior
of various 'white-space' values:
New Lines
Spaces and Tabs
Text Wrapping
End-of-line [=spaces=]
End-of-line [=other space separators=]
''white-space/normal''
Collapse
Collapse
Wrap
Remove
Hang
''pre''
Preserve
Preserve
No wrap
Preserve
No wrap
''white-space/nowrap''
Collapse
Collapse
No wrap
Remove
Hang
''pre-wrap''
Preserve
Preserve
Wrap
Hang
Hang
''break-spaces''
Preserve
Preserve
Wrap
Wrap
Wrap
''pre-line''
Preserve
Collapse
Wrap
Remove
Hang
white-space/trailing-space-and-text-alignment-002.html
white-space/trailing-space-and-text-alignment-rtl-002.html
See [[#white-space-processing|White Space Processing Rules]]
for details on how [=white space=] collapses.
See [[#line-breaking|Line Breaking]]
for details on wrapping behavior.
White Space Processing & Control Characters
The source text of a document often contains formatting
that is not relevant to the final rendering:
for example,
breaking the source into segments
(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
(which is controlled with the 'white-space' property)
interprets [=white space characters=] only for rendering:
it has no effect on the underlying document data.
Note: Depending on the document language,
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 RECORD-START and RECORD-END tokens.
For CSS processing,
each document language–defined “segment break” or “newline sequence”--
or if none are defined, each line feed (U+000A)--
in the text is treated as a segment break,
which is then interpreted for rendering as specified by the 'white-space' property.
In the case of HTML,
[[html#newlines|newlines]] are [=normalize newlines|normalized=] to line feed characters (U+000A)
for representation in the DOM,
so when an HTML document is represented as a DOM tree
each line feed (U+000A)
is treated as a [=segment break=].
[[HTML]]
[[DOM]]
Note: In most common CSS implementations,
HTML does not get styled directly.
Instead, it is processed into a DOM tree,
which is then styled.
Unlike HTML,
the DOM does not give any particular meaning to carriage returns (U+000D),
so they are not treated as [=segment breaks=].
If carriage returns (U+000D) are inserted into the DOM
by means other than HTML parsing,
they then get treated as defined below.
white-space-processing-005.xht
white-space-processing-006.xht
white-space-processing-007.xht
Note: A document parser might
not only normalize any [=segment breaks=],
but also collapse other space characters or
otherwise process white space according to markup rules.
Because CSS processing occurs after 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.
Note: Anonymous blocks consisting entirely of [=collapsible=] [=white space=]
are removed from the rendering tree.
Thus any such [=white space=] surrounding a block-level element is collapsed away.
See [[CSS2/visuren#anonymous]].
[[CSS2]]
Control characters ([=Unicode category=] Cc)--
other than tabs (U+0009),
line feeds (U+000A),
carriage returns (U+000D)
and sequences that form a [=segment break=]--
must be rendered as a visible glyph
which the UA must synthesize if the glyphs found in the font are not visible,
and must be otherwise treated as any other character
of the Other Symbols (So) [=general category=] and Common [=Unicode Script|script=].
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 Default_ignorable characters
must be ignored for text rendering.
[[!UNICODE]]
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
control-characters-001.html
control-characters-002.xht
white-space-control-characters-001.xht
Carriage returns (U+000D) are treated identically to spaces (U+0020) in all respects.
white-space/control-chars-00D.html
white-space-processing-005.xht
white-space-processing-006.xht
white-space-processing-007.xht
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 CARRIAGE RETURN to CSS.
[[HTML]]
[[INFRA]])
However, the character is preserved--
and the above rule observable--
when encoded using an escape sequence (
).
The White Space Processing Rules
Except where specified otherwise,
white space processing in CSS affects only
the document white space characters:
spaces (U+0020), tabs (U+0009), and [[#white-space-processing|segment breaks]].
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
white-space/display-contents-remove-whitespace-change.html
white-space/remove-slotted-with-whitespace-sibling.html
Note: The set of characters considered [=document white space=]
(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.
Besides space (U+0020)
and no-break space (U+00A0),
Unicode defines a number of additional space separator characters.
[[UNICODE]]
In this specification
all characters in the Unicode [=general category=] Zs
except space (U+0020)
and no-break space (U+00A0)
are collectively referred to as
other space separators.
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
Phase I: Collapsing and Transformation
For each inline
(including anonymous inlines;
see [[CSS2/visuren#anonymous]] [[CSS2]])
within an [=inline formatting context=],
[=white space characters=] are processed as follows
prior to [=line breaking=] and [[css-writing-modes-4#text-direction|bidi reordering]],
ignoring bidi formatting characters
(characters with the Bidi_Control property [[!UAX9]])
as if they were not there:
white-space/white-space-collapse-002.html
white-space/white-space-normal-011.html
white-space/white-space-nowrap-011.html
If 'white-space' is set to ''white-space/normal'', ''white-space/nowrap'', or ''pre-line'',
[=white space characters=] are considered collapsible
and are processed by performing the following steps:
Any sequence of collapsible [=spaces=] and [=tabs=]
immediately preceding or following a [=segment break=]
is removed.
white-space/white-space-normal-011.html
white-space/white-space-nowrap-011.html
line-breaking/segment-break-transformation-unremovable-3.html
line-breaking/segment-break-transformation-unremovable-4.html
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
Collapsible [=segment breaks=] are transformed for rendering
according to the [[#line-break-transform|segment break transformation rules]].
Every [=collapsible=] [=tab=] is converted to a collapsible space (U+0020).
white-space/white-space-collapse-000.html
white-space/white-space-normal-011.html
white-space/white-space-nowrap-011.html
white-space-processing-019.xht
white-space-processing-020.xht
white-space-processing-021.xht
Any [=collapsible=] [=space=] immediately following another [=collapsible=] [=space=]--
even one outside the boundary of the inline containing that [=space=],
provided both [=spaces=] are within the same inline formatting context--
is collapsed to have zero advance width.
(It is invisible,
but retains its [=soft wrap opportunity=],
if any.)
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
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
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 [=soft wrap opportunity=] exists at the end of a sequence of [=spaces=] and/or [=tabs=],
while for ''break-spaces'',
a [=soft wrap opportunity=] exists after every [=space=] and every [=tab=].
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/break-spaces-before-first-ideographic-char-001.html
white-space/break-spaces-before-first-ideographic-char-002.html
white-space/break-spaces-before-first-ideographic-char-003.html
white-space/break-spaces-before-first-ideographic-char-004.html
white-space/break-spaces-before-first-ideographic-char-005.html
white-space/break-spaces-before-first-ideographic-char-006.html
white-space/break-spaces-before-first-ideographic-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
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
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):
<ltr>A<rtl>B</rtl>C</ltr>
where the <ltr> element represents a left-to-right embedding
and the <rtl> 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:
The [=space=] before the B ()
will collapse with the [=space=] after the A ().
The [=space=] before the C ()
will collapse with the [=space=] after the B ().
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:
ABC
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.
white-space-bidirectionality-001.xht
Phase II: Trimming and Positioning
Then, the entire block is rendered.
Inlines are laid out,
taking [[css-writing-modes-4#text-direction|bidi reordering]] into account,
and [=wrapping=] as specified by the 'white-space' property.
As each line is laid out,
A sequence of [=collapsible=] [=spaces=] at the beginning of a line
is removed.
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
white-space/full-width-leading-spaces-001.html
white-space/full-width-leading-spaces-002.html
white-space/full-width-leading-spaces-003.html
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
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 [=tab stop=].
If this distance is less than ''0.5ch'',
then the subsequent [=tab stop=] is used instead.
Tab stops 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.
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
white-space-processing-042.xht
Note: See the Unicode rules on how tabulation (U+0009) interacts with bidi. [[UAX9]]
bidi/bidi-tab-001.html
white-space/tab-bidi-001.html
A sequence of [=collapsible=] [=spaces=]
at the end of a line is removed,
as well as any trailing U+1680 OGHAM SPACE MARK
whose 'white-space' property is ''white-space/normal'', ''white-space/nowrap'', or ''pre-line''.
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
overflow-wrap/overflow-wrap-anywhere-011.html
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
Note: Due to Unicode Bidirectional Algorithm rule L1,
a sequence of [=collapsible=] [=spaces=] located at the end of the line
prior to [[css-writing-modes-4#text-direction|bidi reordering]]
will also be at the end of the line after reordering.
[[UAX9]]
[[CSS-WRITING-MODES-4]]
white-space/eol-spaces-bidi-001.html
white-space/eol-spaces-bidi-003.html
white-space/trailing-space-rtl-001.html
If there remains any sequence of [=white space=],
[=other space separators=],
and/or [=preserved=] [=tabs=]
at the end of a line
(after [[css-writing-modes-4#text-direction|bidi reordering]] [[CSS-WRITING-MODES-4]]):
If 'white-space' is set to ''white-space/normal'',
''white-space/nowrap'',
or ''white-space/pre-line'',
the UA must [=hang=] this sequence (unconditionally).
white-space/trailing-ideographic-space-001.html
white-space/trailing-ideographic-space-002.html
white-space/trailing-ideographic-space-005.html
white-space/trailing-ideographic-space-006.html
white-space/trailing-ideographic-space-007.html
white-space/trailing-ideographic-space-008.html
white-space/trailing-ideographic-space-009.html
white-space/trailing-ideographic-space-010.html
white-space/trailing-ideographic-space-011.html
white-space/trailing-ideographic-space-012.html
white-space/trailing-ideographic-space-013.html
white-space/trailing-ideographic-space-014.html
white-space/trailing-ideographic-space-015.html
white-space/trailing-ideographic-space-016.html
white-space/trailing-ideographic-space-017.html
white-space/trailing-ideographic-space-018.html
white-space/trailing-ideographic-space-019.html
white-space/trailing-ideographic-space-020.html
white-space/trailing-ideographic-space-021.html
white-space/trailing-ideographic-space-022.html
white-space/trailing-ideographic-space-023.html
white-space/trailing-ideographic-space-024.html
white-space/trailing-ideographic-space-025.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
white-space/trailing-space-and-text-alignment-001.html
white-space/trailing-space-and-text-alignment-005.html
white-space/trailing-space-and-text-alignment-rtl-001.html
white-space/trailing-space-and-text-alignment-rtl-005.html
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 instead.
It may also visually collapse the character advance widths
of any that would otherwise overflow.
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/white-space-intrinsic-size-005.html
white-space/white-space-intrinsic-size-006.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
white-space/trailing-space-and-text-alignment-003.html
white-space/trailing-space-and-text-alignment-rtl-003.html
white-space/white-space-pre-wrap-trailing-spaces-021.html
white-space/white-space-pre-wrap-trailing-spaces-022.html
white-space/white-space-pre-wrap-trailing-spaces-023.html
overflow-wrap/overflow-wrap-min-content-size-009.html
text-justify/text-justify-and-trailing-spaces-001.html
text-justify/text-justify-and-trailing-spaces-002.html
text-justify/text-justify-and-trailing-spaces-003.html
text-justify/text-justify-and-trailing-spaces-004.html
text-justify/text-justify-and-trailing-spaces-005.html
text-justify/text-justify-and-trailing-spaces-006.html
white-space/pre-wrap-align-center-001.html
white-space/pre-wrap-align-center-002.html
white-space/pre-wrap-align-center-003.html
white-space/pre-wrap-align-end-001.html
white-space/pre-wrap-align-end-002.html
white-space/pre-wrap-align-end-003.html
white-space/pre-wrap-align-left-001.html
white-space/pre-wrap-align-left-002.html
white-space/pre-wrap-align-left-003.html
white-space/pre-wrap-align-right-001.html
white-space/pre-wrap-align-right-002.html
white-space/pre-wrap-align-right-003.html
white-space/pre-wrap-align-start-001.html
white-space/pre-wrap-align-start-002.html
white-space/pre-wrap-align-start-003.html
white-space/white-space-pre-wrap-justify-001.html
white-space/white-space-pre-wrap-justify-002.html
white-space/white-space-pre-wrap-justify-003.html
white-space/white-space-pre-wrap-justify-004.html
Note: [=Hanging=] the white space rather than collapsing it
allows users to see the space when selecting or editing text.
If 'white-space' is set to ''break-spaces'',
[=spaces=], [=tabs=], and [=other space separators=]
are treated the same as other visible characters:
they cannot [=hang=] nor have their advance width collapsed.
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
white-space/break-spaces-with-ideographic-space-001.html
white-space/break-spaces-with-ideographic-space-001.html
white-space/break-spaces-with-ideographic-space-005.html
white-space/break-spaces-with-ideographic-space-007.html
white-space/break-spaces-with-ideographic-space-008.html
white-space/break-spaces-with-ideographic-space-009.html
white-space/break-spaces-with-ideographic-space-010.html
white-space/trailing-ideographic-space-break-spaces-001.html
white-space/trailing-ideographic-space-break-spaces-002.html
white-space/trailing-ideographic-space-break-spaces-003.html
white-space/trailing-ideographic-space-break-spaces-004.html
white-space/trailing-ideographic-space-break-spaces-005.html
white-space/trailing-ideographic-space-break-spaces-006.html
white-space/trailing-ideographic-space-break-spaces-007.html
white-space/trailing-ideographic-space-break-spaces-008.html
white-space/trailing-space-and-text-alignment-004.html
white-space/trailing-space-and-text-alignment-rtl-004.html
Note: Such characters therefore take up space,
and depending on the available space
and applicable line breaking controls
will either overflow or cause the line to wrap.
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.
Since the final [=space=] is before a forced line break
and does not overflow,
it does not hang,
and centering works as expected.
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=].
If p { text-align: right; } was added,
the result would be as follows:
0 0 0 0
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 with 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.
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.
The last line is not wrapped before the last 0
because characters that [=conditionally hang=] are not considered
when measuring the line’s contents for fit.
Segment Break Transformation Rules
When 'white-space' is ''pre'', ''pre-wrap'', ''break-spaces'', or ''pre-line'',
[=segment breaks=] are not [=collapsible=]
and are instead transformed into a preserved line feed (U+000A).
white-space-008.xht
white-space-processing-016.xht
white-space-processing-017.xht
white-space-processing-018.xht
For other values of 'white-space',
[=segment breaks=] are [=collapsible=],
and are collapsed as follows:
First, any collapsible [=segment break=]
immediately following another collapsible [=segment break=]
is removed.
line-breaking/segment-break-transformation-unremovable-2.html
line-breaking/segment-break-transformation-unremovable-4.html
Then any remaining [=segment break=]
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.
line-breaking/segment-break-transformation-unremovable-1.html
line-breaking/segment-break-transformation-unremovable-2.html
line-breaking/segment-break-transformation-unremovable-3.html
line-breaking/segment-break-transformation-unremovable-4.html
white-space/seg-break-transformation-000.tentative.html
white-space/seg-break-transformation-001.tentative.html
white-space/seg-break-transformation-002.tentative.html
white-space/seg-break-transformation-003.tentative.html
white-space/seg-break-transformation-004.tentative.html
white-space/seg-break-transformation-005.tentative.html
white-space/seg-break-transformation-006.tentative.html
white-space/seg-break-transformation-007.tentative.html
white-space/seg-break-transformation-008.tentative.html
white-space/seg-break-transformation-009.tentative.html
white-space/seg-break-transformation-010.tentative.html
white-space/seg-break-transformation-011.tentative.html
white-space/seg-break-transformation-012.tentative.html
white-space/seg-break-transformation-014.tentative.html
white-space/seg-break-transformation-015.tentative.html
white-space/seg-break-transformation-016.tentative.html
white-space/seg-break-transformation-017.tentative.html
white-space/seg-break-transformation-018.tentative.html
white-space/seg-break-transformation-019.tentative.html
line-breaking/segment-break-transformation-removable-1.html
line-breaking/segment-break-transformation-removable-2.html
line-breaking/segment-break-transformation-removable-3.html
line-breaking/segment-break-transformation-removable-4.html
line-breaking/segment-break-transformation-rules-001.html
line-breaking/segment-break-transformation-rules-002.html
line-breaking/segment-break-transformation-rules-003.html
line-breaking/segment-break-transformation-rules-004.html
line-breaking/segment-break-transformation-rules-005.html
line-breaking/segment-break-transformation-rules-006.html
line-breaking/segment-break-transformation-rules-007.html
line-breaking/segment-break-transformation-rules-008.html
line-breaking/segment-break-transformation-rules-009.html
line-breaking/segment-break-transformation-rules-010.html
line-breaking/segment-break-transformation-rules-011.html
line-breaking/segment-break-transformation-rules-012.html
line-breaking/segment-break-transformation-rules-013.html
line-breaking/segment-break-transformation-rules-014.html
line-breaking/segment-break-transformation-rules-015.html
line-breaking/segment-break-transformation-rules-016.html
line-breaking/segment-break-transformation-rules-017.html
line-breaking/segment-break-transformation-rules-018.html
line-breaking/segment-break-transformation-rules-019.html
line-breaking/segment-break-transformation-rules-020.html
line-breaking/segment-break-transformation-rules-021.html
line-breaking/segment-break-transformation-rules-022.html
line-breaking/segment-break-transformation-rules-023.html
line-breaking/segment-break-transformation-rules-024.html
line-breaking/segment-break-transformation-rules-025.html
line-breaking/segment-break-transformation-rules-026.html
line-breaking/segment-break-transformation-rules-027.html
line-breaking/segment-break-transformation-rules-028.html
line-breaking/segment-break-transformation-rules-029.html
line-breaking/segment-break-transformation-rules-030.html
line-breaking/segment-break-transformation-rules-031.html
line-breaking/segment-break-transformation-rules-032.html
line-breaking/segment-break-transformation-rules-033.html
line-breaking/segment-break-transformation-rules-034.html
line-breaking/segment-break-transformation-rules-035.html
line-breaking/segment-break-transformation-rules-036.html
line-breaking/segment-break-transformation-rules-037.html
line-breaking/segment-break-transformation-rules-038.html
line-breaking/segment-break-transformation-rules-039.html
line-breaking/segment-break-transformation-rules-040.html
line-breaking/segment-break-transformation-rules-041.html
line-breaking/segment-break-transformation-rules-042.html
line-breaking/segment-break-transformation-rules-043.html
line-breaking/segment-break-transformation-rules-044.html
line-breaking/segment-break-transformation-rules-045.html
line-breaking/segment-break-transformation-rules-046.html
line-breaking/segment-break-transformation-rules-047.html
line-breaking/segment-break-transformation-rules-048.html
line-breaking/segment-break-transformation-rules-049.html
Note: The white space processing rules have already
removed any [=tabs=] and [=spaces=] around the [=segment break=]
before this context is evaluated.
The purpose of the segment break transformation rules
(and white space collapsing in general)
is to “unbreak” text that has been
[[#white-space-processing|broken into segments]]
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=].
In languages that have no word separators, such as Chinese,
“unbreaking” a line requires joining the two lines with no intervening space.
The segment break transformation rules can use adjacent context
to either transform the segment break into a space
or eliminate it entirely.
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 heuristics need to be conservative about where they discard [=segment breaks=]
even as they strive to improve support for such languages.
Tab Character Size: the 'tab-size' property
Name: tab-size
Value: <> | <>
Initial: 8
Applies to: text
Inherited: yes
Computed value: the specified number or absolute length
Animation type: by computed value type
Canonical order: n/a
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-computed-value-001.html
tab-size/tab-size-inline-001.html
animations/tab-size-interpolation.html
This property determines the tab size
used to render [=preserved=] tab characters (U+0009).
A <> 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.
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-integer-005.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
tab-size/tab-size-spacing-002.html
tab-size/tab-size-spacing-003.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
tab-size/tab-size-block-ancestor.html
white-space/white-space-zero-fontsize-002.html
white-space-processing-042.xht
Line Breaking and Word Boundaries
When inline-level content is laid out into lines, it is broken across line boxes.
Such a break is called a line break.
When a line is broken due to explicit line-breaking controls
(such as a preserved newline character),
or due to the start or end of a block,
it is a forced line break.
When a line is broken due to content wrapping
(i.e. when the UA creates unforced line breaks
in order to fit the content within the measure),
it is a soft wrap break.
The process of breaking inline-level content into lines is called line breaking.
Wrapping is only performed at an allowed break point,
called a soft wrap opportunity.
When wrapping is enabled (see 'white-space'),
the UA must minimize the amount of content overflowing a line
by wrapping the line at a [=soft wrap opportunity=],
if one exists.
line-breaking/line-breaking-020.html
In most writing systems,
in the absence of hyphenation a [=soft wrap opportunity=] occurs only at word boundaries.
Many such systems use [=spaces=] or punctuation to explicitly separate words,
and [=soft wrap opportunities=] 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 [=soft wrap opportunities=] in such texts.
In some other writing systems,
[=soft wrap opportunities=] 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 [=typographic letter unit=],
and thus line breaking conventions allow the line to break
anywhere except between certain character combinations.
Additionally the level of strictness in these restrictions
varies with the typesetting style.
line-breaking/line-breaking-023.html
line-breaking/line-breaking-024.html
line-breaking/line-breaking-025.html
line-breaking/line-breaking-026.html
line-breaking/line-breaking-027.html
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
word-break/word-break-normal-002.html
word-break/word-break-normal-003.html
word-break/word-break-normal-bo-000.html
word-break/word-break-normal-en-000.html
word-break/word-break-normal-ethiopic.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-th-001.html
word-break/word-break-normal-zh-000.html
While CSS does not fully define where [=soft wrap opportunities=] occur,
some controls are provided to distinguish common variations:
The 'line-break' property allows choosing various levels of “strictness”
for line breaking restrictions.
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.
The 'hyphens' property controls whether automatic hyphenation
is allowed to break words in scripts that hyphenate.
The 'overflow-wrap' property allows the UA to take a break anywhere
in otherwise-unbreakable strings that would otherwise overflow.
The interaction of [=line breaking=] and bidirectional text is defined by
[[css-writing-modes-4#bidi-algo]]
and the Unicode Bidirectional Algorithm
(UAX9§3.4 Reordering Resolved Levels in particular).
[[!CSS-WRITING-MODES-4]]
[[!UAX9]]
bidi-breaking-001.xht
bidi-breaking-002.xht
bidi-breaking-003.xht
Preserved segment breaks, and--
regardless of the 'white-space' value--
any Unicode character with the BK and NL line breaking class,
must be treated as forced line breaks.
[[!UAX14]]
line-breaking/line-breaking-022.html
Note: The bidi implications of such [=forced line breaks=]
are defined by the Unicode Bidirectional Algorithm.
[[!UAX9]]
Except where explicitly defined otherwise
(e.g. for ''line-break: anywhere'' or ''overflow-wrap: anywhere'')
line breaking behavior defined for
the WJ,
ZW,
GL,
and ZWJ
Unicode line breaking classes
must be honored.
[[!UAX14]]
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
UAs that allow wrapping at punctuation
other than [=word separators=]
in writing systems that use them
should prioritize breakpoints.
(For example, if breaks after slashes are given a lower priority than spaces,
the sequence “check /etc” will never break between the "/" and the "e".)
As long as care is taken to avoid such awkward breaks,
allowing breaks at appropriate punctuation other than [=word separators=]
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 [=soft wrap opportunities=].
Prioritization of [=word separators=] is not expected,
however,
if ''word-break: break-all'' is specified
(since this value explicitly requests line breaking behavior
not based on breaking at [=word separators=])--
and is forbidden under ''line-break: anywhere''.
Out-of-flow elements
and inline element boundaries
do not introduce a [=forced line break=]
or [=soft wrap opportunity=] in the flow.
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
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,
including U+00A0 NO-BREAK SPACE.
However,
with the exception of U+00A0 NO-BREAK SPACE,
there must be no [=soft wrap opportunity=]
between [=atomic inlines=] and adjacent characters
belonging to the Unicode GL, WJ, or ZWJ line breaking classes.
[[UAX14]]
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-atomic-010.html
line-breaking/line-breaking-atomic-011.html
line-breaking/line-breaking-atomic-012.html
line-breaking/line-breaking-atomic-013.html
line-breaking/line-breaking-atomic-014.html
line-breaking/line-breaking-atomic-015.html
line-breaking/line-breaking-atomic-016.html
line-breaking/line-breaking-atomic-017.html
line-breaking/line-breaking-atomic-018.html
line-breaking/line-breaking-atomic-019.html
line-breaking/line-breaking-atomic-020.html
line-breaking/line-breaking-atomic-021.html
line-breaking/line-breaking-atomic-022.html
line-breaking/line-breaking-atomic-023.html
line-breaking/line-breaking-atomic-024.html
line-breaking/line-breaking-atomic-025.html
line-breaking/line-breaking-atomic-026.html
line-breaking/line-breaking-atomic-027.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
For [=soft wrap opportunities=] 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 [=soft wrap opportunities=] defined by the boundary between two characters,
the 'white-space' property
on the nearest common ancestor of the two characters
controls breaking;
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.
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/break-boundary-2-chars-001.html
overflow-wrap/overflow-wrap-anywhere-inline-002.tentative.html
overflow-wrap/overflow-wrap-anywhere-inline-003.tentative.html
overflow-wrap/overflow-wrap-anywhere-inline-004.tentative.html
word-break/word-break-break-all-inline-004.tentative.html
word-break/word-break-break-all-inline-007.tentative.html
word-break/word-break-break-all-inline-010.tentative.html
For [=soft wrap opportunities=] 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.
Line breaking in/around Ruby is defined
in [[css-ruby-1#line-breaks]].
[[!CSS-RUBY-1]]
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.
line-breaking/line-breaking-023.html
line-breaking/line-breaking-024.html
line-breaking/line-breaking-025.html
line-breaking/line-breaking-026.html
line-breaking/line-breaking-027.html
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.
Breaking Rules for Letters: the 'word-break' property
Name: word-break
Value: normal | keep-all | break-all | break-word
Initial: normal
Applies to: text
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
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.tentative.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.tentative.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
This property specifies [=soft wrap opportunities=] between letters,
i.e. where it is “normal” and permissible to break lines of text.
Specifically it controls whether a [=soft wrap opportunity=]
generally exists
between adjacent [=typographic letter units=],
treating non-[=letter=] [=typographic character units=]
belonging to the
NU,
AL,
AI,
or ID
Unicode line breaking classes
as [=typographic letter units=] for this purpose (only).
[[!UAX14]]
It does not affect rules governing the [=soft wrap opportunities=]
created by [=white space=]
(as well as by [=other space separators=])
and around punctuation.
(See 'line-break' for controls affecting punctuation and small kana.)
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-min-content-003.html
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''.
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'').
각 줄의 마지막에 한글이 올 때 줄 나눔 기
준을 “글자” 또는 “어절” 단위로 한다.
각 줄의 마지막에 한글이 올 때 줄 나눔
기준을 “글자” 또는 “어절” 단위로 한다.
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'').
Note: To enable additional break opportunities only in the case of overflow,
see 'overflow-wrap'.
Values have the following meanings:
normal
Words break according to their customary rules,
as described [[#line-breaking|above]].
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.
word-break/word-break-normal-001.html
word-break/word-break-normal-002.html
word-break/word-break-normal-003.html
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-th-001.html
word-break/word-break-normal-zh-000.html
word-break/word-break-normal-ethiopic.html
break-all
Breaking is allowed within “words”:
specifically,
in addition to [=soft wrap opportunities=] allowed for ''word-break/normal'',
any [=typographic letter units=]
(and any [=typographic character units=] resolving to the
NU (“numeric”),
AL (“alphabetic”),
or SA (“Southeast Asian”)
line breaking classes [[!UAX14]])
are instead treated as ID
(“ideographic characters”)
for the purpose of line-breaking.
Hyphenation is not applied.
line-break/line-break-loose-hyphens-002.html
line-break/line-break-normal-hyphens-002.html
line-break/line-break-strict-hyphens-002.html
overflow-wrap/overflow-wrap-anywhere-006.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
white-space/break-spaces-before-first-ideographic-char-004.html
white-space/break-spaces-before-first-ideographic-char-005.html
white-space/break-spaces-before-first-ideographic-char-006.html
word-break/break-boundary-2-chars-002.html
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-010.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-031.html
word-break/word-break-break-all-032.html
word-break/word-break-break-all-ethiopic.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.tentative.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.tentative.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.tentative.html
Note: This value does not affect
whether there are [=soft wrap opportunities=]
around punctuation characters.
To allow breaks anywhere, see ''line-break: anywhere''.
white-space/break-spaces-before-first-char-011.html
white-space/break-spaces-before-first-ideographic-char-011.html
word-break/word-break-break-all-ethiopic.html
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.
keep-all
Breaking is forbidden within “words”:
implicit [=soft wrap opportunities=] between [=typographic letter units=]
(or other [=typographic character units=]
belonging to the
NU,
AL,
AI,
or ID
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.
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
word-break/word-break-keep-all-009.html
word-break/word-break-keep-all-010.html
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.
Symbols that line-break the same way as letters of a particular category
are affected the same way as those letters.
Here’s a mixed-script sample text:
这是一些汉字 and some Latin و کمی خط عربی และตัวอย่างการเขียนภาษาไทย በጽሑፍ፡ማራዘሙን፡አንዳንድ፡
The break-points are determined as follows (indicated by ‘·’):
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:
窓ぎわのトットちゃん
h1 { word-break: normal }
h1 { word-break: keep-all }
Expected rendering
窓ぎわのトットちゃ
ん
窓ぎわの
トットちゃん
Result in your browser
窓ぎわのトットちゃん
窓ぎわのトットちゃん
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 [[#word-break-shaping|not broken]]
(see [[#word-break-shaping]]).
word-break/word-break-break-all-004.html
For compatibility with legacy content,
the 'word-break' property also supports
a deprecated break-word 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.
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
white-space/break-spaces-before-first-ideographic-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
white-space/break-spaces-with-ideographic-space-002.html
white-space/break-spaces-with-ideographic-space-004.html
white-space/break-spaces-with-ideographic-space-006.html
white-space/break-spaces-with-ideographic-space-008.html
white-space/break-spaces-with-ideographic-space-009.html
word-break/word-break-min-content-007.html
Line Breaking Strictness: the 'line-break' property
Name: line-break
Value: auto | loose | normal | strict | anywhere
Initial: auto
Applies to: text
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
inheritance.html
parsing/line-break-valid.html
parsing/line-break-invalid.html
parsing/line-break-computed.html
animations/line-break-no-interpolation.html
This property specifies the strictness of line-breaking rules applied
within an element:
especially how [=wrapping=] interacts with punctuation and symbols.
Values have the following meanings:
auto
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.
loose
Breaks text using the least restrictive set of line-breaking
rules. Typically used for short lines, such as in newspapers.
normal
Breaks text using the most common set of line-breaking rules.
strict
Breaks text using the most stringent set of line-breaking rules.
anywhere
There is a [=soft wrap opportunity=] around every [=typographic character unit=],
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 line breaking classes
or mandated by the 'word-break' property.
[[UAX14]]
The different wrapping opportunities must not be prioritized.
Hyphenation is not applied.
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
white-space/break-spaces-before-first-ideographic-char-007.html
white-space/break-spaces-before-first-ideographic-char-011.html
Note: This value triggers the line breaking rules typically seen in terminals.
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 altogether (''white-space/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.
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:
The following breaks are forbidden in ''strict'' line breaking
and allowed in ''line-break/normal'' and ''loose'':
breaks before Japanese small kana
or the Katakana-Hiragana prolonged sound mark,
i.e. characters
from the Unicode line breaking class CJ.
[[!UAX14]]
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
The following breaks are allowed for ''line-break/normal''
and ''loose'' line breaking
if the [=writing system=] is Chinese
or Japanese,
and are otherwise forbidden:
The following breaks are allowed for ''loose'' line breaking
if the preceding character
belongs to the Unicode line breaking class ID
[[!UAX14]]
(including when the preceding character
is treated as ID
due to ''word-break: break-all''),
and are otherwise forbidden:
breaks between inseparable characters
(such as ‥ U+2025, … U+2026)
i.e. characters from the Unicode line breaking class IN.
[[!UAX14]]
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
The following breaks are allowed for ''loose''
if the [=writing system=] is Chinese
or Japanese
and are otherwise forbidden:
breaks before suffixes:
Characters with the Unicode line breaking class PO
[[!UAX14]]
and the [=East Asian Width property=]
[[!UAX11]]
Ambiguous,
Fullwidth,
or Wide.
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
breaks after prefixes:
Characters with the Unicode line breaking class PR
[[!UAX14]]
and the [=East Asian Width property=]
[[!UAX11]]
Ambiguous,
Fullwidth,
or Wide.
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
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
Chinese or Japanese.
Future levels may add additional specific rules
for other writing systems and languages
as their requirements become known.
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''
(ตัวอย่าง·การ·เขียน·ภาษา·ไทย).
Note: The CSSWG recognizes that in a future edition of the specification
finer control over line breaking may be necessary
to satisfy high-end publishing requirements.
Hyphenation: the 'hyphens' property
Hyphenation
is the controlled splitting of words
where they usually would not be allowed to break
to improve the layout of paragraphs,
typically splitting words at syllabic or morphemic boundaries
and often visually indicating the split
(usually by inserting a hyphen, U+2010).
In some cases, hyphenation may also alter the spelling of a word.
Regardless, hyphenation is a rendering effect only:
it must have no effect on the underlying document content
or on text selection or searching.
hyphens/hyphens-character.html
hyphens/hyphens-vertical-001.html
hyphens/hyphens-vertical-002.html
Hyphenation practices vary across languages,
and can involve not just inserting a hyphen before the line break,
but inserting a hyphen after the break (or both),
inserting a different character than U+2010,
or changing the spelling of the word.
Language
Unbroken
Before
After
English
Unbroken
Un‐
broken
Dutch
cafeetje
café‐
tje
Hungarian
Összeg
Ösz‐
szeg
Mandarin
tú’àn
tú‐
àn
àizēng‐fēnmíng
àizēng‐
‐fēnmíng
Uyghur
Cree
hyphens/i18n/hyphens-i18n-auto-001.html
hyphens/i18n/hyphens-i18n-auto-002.html
hyphens/i18n/hyphens-i18n-auto-003.html
hyphens/i18n/hyphens-i18n-auto-004.html
hyphens/i18n/hyphens-i18n-auto-005.html
hyphens/i18n/hyphens-i18n-auto-006.html
Hyphenation occurs
when the line breaks at a valid hyphenation opportunity,
which is a type of [=soft wrap opportunity=]
that exists within a word where [=hyphenation=] is allowed.
In CSS [=hyphenation opportunities=] are controlled
with the 'hyphens' property.
CSS Text Level 3 does not define the exact rules for [=hyphenation=];
however UAs are strongly encouraged
to optimize their choice of break points
and to chose language-appropriate hyphenation points.
hyphens/hyphens-overflow-001.html
Note: The [=soft wrap opportunity=] introduced by
the U+002D - HYPHEN-MINUS character
or the U+2010 ‐ HYPHEN character
is not a [=hyphenation opportunity=],
as no visual indication of the split is created when wrapping:
these characters are visible whether the line is wrapped at that point or not.
Hyphenation opportunities are considered when calculating
[=min-content size|min-content intrinsic sizes=].
hyphens/hyphens-auto-min-content.html
Note: This allows tables to hyphenate their contents
instead of overflowing their containing block,
which is particularly important in long-word languages like German.
Name: hyphens
Value: none | manual | auto
Initial: manual
Applies to: text
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
inheritance.html
parsing/hyphens-valid.html
parsing/hyphens-invalid.html
parsing/hyphens-computed.html
hyphens/hyphens-auto-inline-010.html
hyphens/hyphens-manual-inline-010.html
hyphens/hyphens-manual-inline-011.html
hyphens/hyphens-manual-inline-012.html
animations/hyphen-no-interpolation.html
This property controls whether [=hyphenation=] is allowed to create more
[=soft wrap opportunities=] within a line of text.
Values have the following meanings:
none
Words are not hyphenated,
even if characters inside the word
explicitly define [=hyphenation opportunities=].
Note: This does not suppress the existing [=soft wrap opportunities=]
introduced by always visible characters such as
U+002D - HYPHEN-MINUS
or U+2010 ‐ HYPHEN.
hyphens/hyphens-none-011.html
hyphens/hyphens-none-012.html
hyphens/hyphens-none-013.html
hyphens/hyphens-none-014.html
hyphens/hyphens-none-015.html
hyphens/hyphens-none-shy-on-2nd-line-001.html
manual
Words are only hyphenated where there are characters inside the word
that explicitly suggest [=hyphenation opportunities=].
The UA must use the appropriate language-specific hyphenation character(s)
and should apply any appropriate spelling changes
just as for automatic hyphenation at the same point.
hyphens/hyphens-overflow-001.html
hyphens/hyphens-manual-010.html
hyphens/hyphens-manual-011.html
hyphens/hyphens-manual-012.html
hyphens/hyphens-manual-013.html
hyphens/hyphens-out-of-flow-001.html
hyphens/hyphens-shaping-001.html
hyphens/hyphens-shaping-002.html
hyphens/hyphens-span-001.html
hyphens/shy-styling-001.html
hyphens/i18n/hyphens-i18n-manual-001.html
hyphens/i18n/hyphens-i18n-manual-002.html
hyphens/i18n/hyphens-i18n-manual-003.html
hyphens/i18n/hyphens-i18n-manual-004.html
hyphens/i18n/hyphens-i18n-manual-005.html
In Unicode, U+00AD is a conditional "soft hyphen"
and U+2010 is an unconditional hyphen.
Unicode Standard Annex #14
describes the role of soft hyphens in
Unicode line breaking.
[[!UAX14]]
In HTML,
­ represents the soft hyphen character,
which suggests a hyphenation opportunity.
example
auto
Words may be broken at [=hyphenation opportunities=]
determined automatically by a language-appropriate hyphenation resource
in addition to those indicated explicitly by a conditional hyphen.
Automatic [=hyphenation opportunities=] elsewhere within a word must be ignored
if the word contains a conditional hyphen
(­ or U+00AD SOFT HYPHEN),
in favor of the conditional hyphen(s).
However, if, even after breaking at such opportunities,
a portion of that word is still too long to fit on one line,
an automatic hyphenation opportunity may be used.
hyphens/hyphens-auto-control.html
hyphens/hyphens-auto-001.html
hyphens/hyphens-auto-002.html
hyphens/hyphens-auto-003.html
hyphens/hyphens-auto-004.html
hyphens/hyphens-auto-005.html
hyphens/hyphens-auto-010.html
hyphens/hyphens-out-of-flow-002.html
hyphens/hyphens-span-002.html
hyphens/hyphens-auto-and-contenteditable-crash.html
hyphens/hyphens-auto-last-word-001.html
hyphens/hyphens-punctuation-001.html
Correct automatic hyphenation requires a hyphenation resource
appropriate to the language of the text being broken.
The UA must therefore only automatically hyphenate text
for which the content language is known
and for which it has an appropriate hyphenation resource.
hyphens/hyphens-auto-001.html
Authors should correctly tag their content’s [=content language|language=]
(e.g. using the HTML lang attribute
or XML xml:lang attribute)
in order to obtain correct automatic hyphenation.
The UA may use language-tailored heuristics
to exclude certain words
from automatic hyphenation.
For example, a UA might try to avoid hyphenation in proper nouns
by excluding words matching certain capitalization and punctuation patterns.
Such heuristics are not defined by this specification.
(Note that such heuristics will need to vary by language:
English and German, for example, have very different capitalization conventions.)
For the purpose of the 'hyphens' property,
what constitutes a “word” is UA-dependent.
However, inline element boundaries
and out-of-flow elements
must be ignored when determining word boundaries.
hyphens/hyphens-span-001.html
hyphens/hyphens-span-002.html
hyphens/hyphens-out-of-flow-001.html
hyphens/hyphens-out-of-flow-002.html
Any glyphs shown due to hyphenation
at a [=hyphenation opportunity=]
created by a conditional hyphen character
(such as U+00AD SOFT HYPHEN)
are represented by that character
and are styled according to the properties applied to it.
hyphens/shy-styling-001.html
When shaping scripts such as Arabic are allowed to break within words
due to hyphenation,
the characters must still be shaped
as if the word were [[#word-break-shaping|not broken]]
(see [[#word-break-shaping]]).
hyphens/hyphens-shaping-001.html
hyphens/hyphens-shaping-002.html
For example, if the Uyghur word “داميدى”
were hyphenated, it would appear as
not as
.
Overflow Wrapping: the 'overflow-wrap'/'word-wrap' property
Name: overflow-wrap, word-wrap
Value: normal | break-word | anywhere
Initial: normal
Applies to: text
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
inheritance.html
parsing/overflow-wrap-invalid.html
parsing/overflow-wrap-valid.html
parsing/overflow-wrap-computed.html
parsing/word-wrap-invalid.html
parsing/word-wrap-valid.html
parsing/word-wrap-computed.html
overflow-wrap/overflow-wrap-anywhere-span-001.html
overflow-wrap/overflow-wrap-anywhere-span-002.html
overflow-wrap/overflow-wrap-break-word-span-001.html
overflow-wrap/overflow-wrap-break-word-span-002.html
overflow-wrap/overflow-wrap-break-word-long-crash.html
overflow-wrap/overflow-wrap-break-word-white-space-crash.html
overflow-wrap/overflow-wrap-break-word-white-space-crash-002.html
overflow-wrap/overflow-wrap-anywhere-inline-002.tentative.html
This property specifies whether the UA may break
at otherwise disallowed points within a line
to prevent overflow,
when an otherwise-unbreakable string is too long to fit within the line box.
It only has an effect when
'white-space' allows [=wrapping=]. Possible values:
overflow-wrap/overflow-wrap-002.html
normal
Lines may break only at allowed break points.
However,
the restrictions introduced by ''word-break: keep-all'' may be relaxed
to match ''word-break: normal''
if there are no otherwise-acceptable break points in the line.
overflow-wrap/overflow-wrap-004.html
overflow-wrap/overflow-wrap-normal-keep-all-001.html
anywhere
An otherwise unbreakable sequence of [=characters=]
may be broken at an arbitrary point
if there are no otherwise-acceptable break points in the line.
Shaping characters are still shaped
as if the word were not broken,
and grapheme clusters must stay together as one unit.
No hyphenation character is inserted at the break point.
[=Soft wrap opportunities=] introduced by ''overflow-wrap/anywhere''
are considered
when calculating [=min-content size|min-content intrinsic sizes=].
overflow-wrap/overflow-wrap-min-content-size-001.html
overflow-wrap/overflow-wrap-min-content-size-002.html
overflow-wrap/overflow-wrap-min-content-size-003.html
overflow-wrap/overflow-wrap-anywhere-001.html
overflow-wrap/overflow-wrap-anywhere-003.html
overflow-wrap/overflow-wrap-anywhere-006.html
overflow-wrap/overflow-wrap-anywhere-007.html
overflow-wrap/overflow-wrap-anywhere-008.html
overflow-wrap/overflow-wrap-anywhere-009.html
overflow-wrap/overflow-wrap-anywhere-010.html
overflow-wrap/overflow-wrap-anywhere-011.html
overflow-wrap/overflow-wrap-anywhere-inline-001.html
overflow-wrap/overflow-wrap-anywhere-inline-002.tentative.html
overflow-wrap/overflow-wrap-anywhere-inline-003.tentative.html
overflow-wrap/overflow-wrap-anywhere-inline-004.tentative.html
overflow-wrap/overflow-wrap-anywhere-fit-content-001.html
overflow-wrap/overflow-wrap-min-content-size-005.html
overflow-wrap/overflow-wrap-min-content-size-007.html
overflow-wrap/overflow-wrap-cluster-002.html
overflow-wrap/overflow-wrap-shaping-002.html
white-space/break-spaces-before-first-char-009.html
white-space/break-spaces-before-first-char-013.html
white-space/break-spaces-before-first-ideographic-char-009.html
white-space/break-spaces-before-first-ideographic-char-013.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
white-space/pre-wrap-009.html
white-space/pre-wrap-010.html
white-space/break-spaces-with-overflow-wrap-002.html
white-space/break-spaces-with-overflow-wrap-004.html
white-space/break-spaces-with-overflow-wrap-006.html
white-space/break-spaces-with-overflow-wrap-008.html
white-space/break-spaces-with-overflow-wrap-010.html
overflow-wrap/overflow-wrap-min-content-size-009.html
break-word
As for ''overflow-wrap/anywhere''
except that
soft wrap opportunities introduced by ''overflow-wrap/break-word''
are not considered
when calculating [=min-content size|min-content intrinsic sizes=].
overflow-wrap/overflow-wrap-001.html
overflow-wrap/overflow-wrap-break-word-001.html
overflow-wrap/overflow-wrap-break-word-003.html
overflow-wrap/overflow-wrap-break-word-008.html
overflow-wrap/overflow-wrap-break-word-009.html
overflow-wrap/overflow-wrap-break-word-010.html
overflow-wrap/overflow-wrap-min-content-size-004.html
overflow-wrap/overflow-wrap-min-content-size-006.html
overflow-wrap/overflow-wrap-min-content-size-008.html
overflow-wrap/overflow-wrap-break-word-fit-content-001.html
overflow-wrap/overflow-wrap-cluster-001.html
overflow-wrap/overflow-wrap-shaping-001.html
white-space/break-spaces-before-first-char-008.html
white-space/break-spaces-before-first-char-012.html
white-space/break-spaces-before-first-ideographic-char-008.html
white-space/break-spaces-before-first-ideographic-char-012.html
overflow-wrap/overflow-wrap-break-word-keep-all-001.html
white-space/break-spaces-with-overflow-wrap-001.html
white-space/break-spaces-with-overflow-wrap-003.html
white-space/break-spaces-with-overflow-wrap-005.html
white-space/break-spaces-with-overflow-wrap-007.html
white-space/break-spaces-with-overflow-wrap-009.html
white-space/trailing-ideographic-space-013.html
white-space/trailing-ideographic-space-014.html
white-space/trailing-ideographic-space-015.html
white-space/trailing-ideographic-space-016.html
For legacy reasons, UAs must treat 'word-wrap'
as a [=legacy name alias=] of the 'overflow-wrap' property.
overflow-wrap/word-wrap-alias.html
overflow-wrap/word-wrap-001.html
overflow-wrap/word-wrap-002.html
overflow-wrap/word-wrap-004.html
Shaping Across Intra-word Breaks
When shaping scripts such as Arabic
[=wrap=] at unforced [=soft wrap opportunities=] within words
(such as when breaking due to
''word-break: break-all'',
''line-break: anywhere'',
''overflow-wrap: break-word'',
''overflow-wrap: anywhere'',
or when [=hyphenating=])
the characters must still be shaped
(their joining forms chosen)
as if the word were still whole.
hyphens/hyphens-shaping-001.html
hyphens/hyphens-shaping-002.html
line-break/line-break-shaping-001.html
overflow-wrap/overflow-wrap-shaping-001.html
overflow-wrap/overflow-wrap-shaping-002.html
word-break/word-break-break-all-004.html
For example,
if the word “نوشتن” is broken between the “ش” and “ت”,
the “ش” still takes its initial form (“ﺷ”),
and the “ت” its medial form (“ﺘ”)--
forming as in “ﻧﻮﺷ | ﺘﻦ”, not as in “نوش | تن”.
Alignment and Justification
Alignment and justification controls
how inline content is distributed within a line box.
Text Alignment: the 'text-align' shorthand
Name: text-align
Value: start | end | left | right | center | justify | match-parent | justify-all
Initial: start
Applies to: block containers
Inherited: yes
Canonical order: n/a
Animation type: discrete
inheritance.html
parsing/text-align-valid.html
parsing/text-align-invalid.html
parsing/text-align-computed.html
text-align/text-align-webkit-match-parent.html
c546-txt-align-000.xht
text-align-005.xht
text-align-applies-to-001.xht
text-align-applies-to-002.xht
text-align-applies-to-003.xht
text-align-applies-to-005.xht
text-align-applies-to-006.xht
text-align-applies-to-007.xht
text-align-applies-to-008.xht
text-align-applies-to-009.xht
text-align-applies-to-010.xht
text-align-applies-to-011.xht
text-align-applies-to-012.xht
text-align-applies-to-013.xht
text-align-applies-to-014.xht
text-align-applies-to-015.xht
text-align-inherit-001.xht
text-align-bidi-011.xht
This [=shorthand property=]
sets the 'text-align-all' and 'text-align-last' properties
and describes how the inline-level content of a block
is aligned along the inline axis
if the content does not completely fill the line box.
Values other than ''justify-all'' or ''match-parent'' are assigned to 'text-align-all'
and reset 'text-align-last' to ''text-align-last/auto''.
Values have the following meanings:
start
Inline-level content is aligned
to the start edge of the line box.
text-align/text-align-006.html
text-align/text-align-start-001.html
text-align/text-align-start-002.html
text-align/text-align-start-003.html
text-align/text-align-start-004.html
text-align/text-align-start-005.html
text-align/text-align-start-006.html
text-align/text-align-start-007.html
text-align/text-align-start-008.html
text-align/text-align-start-009.html
text-align/text-align-start-010.html
text-align/text-align-start-014.html
text-align/text-align-start-015.html
text-align/text-align-start-016.html
text-align/text-align-start-017.html
text-align/text-align-start-018.html
text-align/text-align-start-019.html
text-align/text-align-start-020.html
text-align/text-align-start-021.html
end
Inline-level content is aligned
to the end edge of the line box.
text-align/text-align-007.html
text-align/text-align-end-001.html
text-align/text-align-end-002.html
text-align/text-align-end-003.html
text-align/text-align-end-004.html
text-align/text-align-end-005.html
text-align/text-align-end-006.html
text-align/text-align-end-007.html
text-align/text-align-end-008.html
text-align/text-align-end-009.html
text-align/text-align-end-010.html
text-align/text-align-end-014.html
text-align/text-align-end-015.html
text-align/text-align-end-016.html
text-align/text-align-end-017.html
text-align/text-align-end-018.html
text-align/text-align-end-019.html
text-align/text-align-end-020.html
text-align/text-align-end-021.html
left
Inline-level content is aligned
to the [=line-left=] edge of the line box.
(In vertical writing modes,
this can be either the physical top or bottom,
depending on 'writing-mode'.)
[[CSS-WRITING-MODES-4]]
text-align-001.xht
text-align-bidi-001.xht
text-align-bidi-006.xht
text-align-bidi-007.xht
right
Inline-level content is aligned
to the [=line-right=]
edge of the line box.
(In vertical writing modes,
this can be either the physical top or bottom,
depending on 'writing-mode'.)
[[CSS-WRITING-MODES-4]]
text-align-002.xht
text-align-bidi-005.xht
center
Inline-level content is centered within the line box.
text-align-003.xht
text-align-bidi-002.xht
text-align-bidi-003.xht
text-align-bidi-004.xht
text-align-inherit-001.xht
text-align/text-align-center-last-center.html
justify
Text is justified
according to the method specified by the 'text-justify' property,
in order to exactly fill the line box.
Unless otherwise specified by 'text-align-last',
the last line before a forced break
or the end of the block
is ''text-align/start''-aligned.
text-align/text-align-justify-001.html
text-align/text-align-justify-002.html
text-align/text-align-justify-003.html
text-align/text-align-justify-004.html
text-align/text-align-justify-005.html
text-align/text-align-justify-006.html
text-align/text-align-justify-shy-001.html
letter-spacing-justify-001.xht
text-align-004.xht
text-align-bidi-008.xht
text-align-bidi-009.xht
text-align-bidi-010.xht
text-align-bidi-012.xht
text-align-bidi-013.xht
text-align-white-space-002.xht
text-align-white-space-004.xht
text-align-white-space-006.xht
text-align-white-space-008.xht
word-spacing-justify-001.xht
justify-all
Sets both 'text-align-all'
and 'text-align-last'
to ''text-align/justify'',
forcing the last line to justify as well.
text-align/text-align-justifyall-001.html
text-align/text-align-justifyall-002.html
text-align/text-align-justifyall-003.html
text-align/text-align-justifyall-004.html
text-align/text-align-justifyall-005.html
text-align/text-align-justifyall-006.html
letter-spacing/letter-spacing-bidi-003.xht
match-parent
This value behaves the same as ''inherit''
(computes to its parent’s computed value)
except that an [=inherited value=] of
''text-align/start'' or ''text-align/end''
is interpreted against the parent’s
'direction' value
and results in a computed value of either
''text-align/left'' or ''text-align/right''.
Computes to ''text-align/start''
when specified on the [=root element=].
text-align/text-align-match-parent-001.html
text-align/text-align-match-parent-002.html
text-align/text-align-match-parent-01.html
text-align/text-align-match-parent-02.html
text-align/text-align-match-parent-03.html
text-align/text-align-match-parent-04.html
text-align/text-align-match-parent-root-ltr.html
text-align/text-align-match-parent-root-rtl.html
text-align/text-align-match-parent-root-logical.html
When specified on the 'text-align' shorthand,
sets both 'text-align-all' and 'text-align-last' to ''text-align/match-parent''.
text-align/text-align-match-parent-05.html
A block of text
is a stack of [=line boxes=].
This property specifies how the inline-level boxes within each line box
align with respect to the start and end sides of the line box.
Alignment is not with respect to the
[[CSS2/visuren#viewport|viewport]]
or containing block.
In the case of ''justify'',
the UA may stretch or shrink any inline boxes
by [[#text-justify-property|adjusting]] their text.
(See 'text-justify'.)
If an element’s [=white space=] is not [=collapsible=],
then the UA is not required to adjust its text
for the purpose of justification
and may instead treat the text
as having no [=justification opportunities=].
If the UA chooses to adjust the text,
then it must ensure
that tab stops continue to line up as required by the
[[#white-space-rules|white space processing rules]].
text-align-white-space-001.xht
text-align-white-space-005.xht
text-align/text-align-justify-tabs-001.html
text-align/text-align-justify-tabs-002.html
text-align/text-align-justify-tabs-003.html
text-align/text-align-justify-tabs-004.html
If (after justification, if any)
the inline contents of a line box are too long to fit within it,
then the contents are start-aligned:
any content that doesn’t fit
overflows the line box’s end edge.
See [[#bidi-linebox]] for details on how to determine
the start and end edges
of a line box.
Default Text Alignment: the 'text-align-all' property
Name: text-align-all
Value: start | end | left | right | center | justify | match-parent
Initial: start
Applies to: block containers
Inherited: yes
Computed value: keyword as specified, except for ''match-parent'' which computes as defined above
Canonical order: n/a
Animation type: discrete
inheritance.html
parsing/text-align-all-valid.html
parsing/text-align-all-invalid.html
This longhand of the 'text-align' [=shorthand property=]
specifies the inline alignment of all lines of inline content in the block container,
except for last lines
overridden by a non-''text-align-last/auto'' value of 'text-align-last'.
See 'text-align' for a full description of values.
Authors should use the 'text-align' shorthand instead of this property.
Last Line Alignment: the 'text-align-last' property
Name: text-align-last
Value: auto | start | end | left | right | center | justify | match-parent
Initial: auto
Applies to: block containers
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
inheritance.html
parsing/text-align-last-valid.html
parsing/text-align-last-invalid.html
parsing/text-align-last-computed.html
text-align/text-align-last-013.html
text-align/text-align-last-014.html
This property describes how the last line of a block or a line
right before a [=forced line break=]
is aligned.
text-align/text-align-last-001.html
text-align/text-align-last-002.html
text-align/text-align-last-003.html
text-align/text-align-last-004.html
text-align/text-align-last-005.html
text-align/text-align-last-006.html
text-align/text-align-last-010.html
text-align/text-align-last-011.html
text-align/text-align-last-012.html
text-align/text-align-last-wins-001.html
If auto is specified,
content on the affected line is aligned per 'text-align-all'
unless 'text-align-all' is set to ''justify'',
in which case it is ''text-align/start''-aligned.
All other values are interpreted as described for 'text-align'.
text-align/text-align-last-007.html
text-align/text-align-last-008.html
text-align/text-align-last-009.html
text-align/text-align-center-last-center.html
text-align/text-align-center-last-default.html
text-align/text-align-center-last-end.html
text-align/text-align-center-last-justify.html
text-align/text-align-center-last-start.html
text-align/text-align-default-last-default.html
text-align/text-align-end-last-center.html
text-align/text-align-end-last-default.html
text-align/text-align-end-last-end.html
text-align/text-align-end-last-justify.html
text-align/text-align-end-last-start.html
text-align/text-align-inline-end-crash.html
text-align/text-align-justify-last-center.html
text-align/text-align-justify-last-default.html
text-align/text-align-justify-last-end.html
text-align/text-align-justify-last-justify.html
text-align/text-align-justify-last-start.html
text-align/text-align-last-center.html
text-align/text-align-last-end.html
text-align/text-align-last-interpolation.html
text-align/text-align-last-justify-rtl.html
text-align/text-align-last-justify.html
text-align/text-align-last-simple.html
text-align/text-align-last-start.html
text-align/text-align-start-last-center.html
text-align/text-align-start-last-default.html
text-align/text-align-start-last-end.html
text-align/text-align-start-last-justify.html
text-align/text-align-start-last-start.html
text-align/text-align-match-parent-05.html
text-align/text-align-last-015.html
Justification Method: the 'text-justify' property
Name: text-justify
Value: auto | none | inter-word | inter-character
Initial: auto
Applies to: text
Inherited: yes
Canonical order: n/a
Computed value: specified keyword (except for the ''distribute'' legacy value)
Animation type: discrete
inheritance.html
parsing/text-justify-valid.html
parsing/text-justify-invalid.html
parsing/text-justify-computed.html
text-justify/text-justify-006.html
text-justify/text-justify-interpolation.html
This property selects the justification method
used when a line’s alignment is set to ''justify''
(see 'text-align').
The property applies to text,
but is inherited from block containers
to the root inline box containing their inline-level contents.
It takes the following values:
text-justify/text-justify-006.html
auto
The UA determines the justification algorithm to follow,
based on a balance between performance and adequate presentation quality.
Since justification rules vary by [=writing system=]
and [=content language|language=],
UAs should, where possible,
use a justification algorithm appropriate to the text.
text/letter-spacing-justify-001.xht
text/word-spacing-justify-001.xht
For example,
the UA could use by default a justification method
that is a simple universal compromise for all writing systems--
such as primarily expanding [=word separators=]
and between CJK [=typographic letter units=]
along with secondarily expanding
between Southeast Asian [=typographic letter units=].
Then, in cases where the [=content language=] of the paragraph is known,
it could choose a more language-tailored justification behavior
e.g. following the Requirements for Japanese Text Layout for Japanese [[JLREQ]],
using cursive elongation for Arabic,
using ''inter-word'' for German,
etc.
none
Justification is disabled:
there are no [=justification opportunities=] within the text.
text-justify/text-justify-001.html
text-justify/text-justify-006.html
text-justify-none-001.html
Note: This value is intended for use in user stylesheets
to improve readability or for accessibility purposes.
inter-word
Justification adjusts spacing at [=word separators=] only
(effectively varying the used 'word-spacing' on the line).
This behavior is typical for languages that separate words using spaces,
like English or Korean.
text-justify-inter-word-001.html
text-justify-word-separators.html
inter-character
Justification adjusts spacing
between each pair of adjacent [=typographic character units=]
(effectively varying the used 'letter-spacing' on the line).
This value is sometimes used in East Asian systems such as Japanese.
text-justify/text-justify-002.html
text-justify-inter-character-001.html
For legacy reasons,
UAs must also support the alternate keyword distribute
which must compute to ''inter-character'',
thus having the exact same meaning and behavior.
UAs may treat this as a [=legacy value alias=].
text-justify/text-justify-003.html
parsing/text-justify-computed-legacy.html
text-justify/text-justify-distribute-001.html
Since optimal justification is [=content language|language=]-sensitive,
authors should correctly language-tag their content for the best results.
Note: The guidelines in this level of CSS
do not describe a complete justification algorithm.
They are merely a minimum set of requirements
that a complete algorithm should meet.
Limiting the set of requirements gives UAs some latitude
in choosing a justification algorithm
that meets their needs and desired balance of quality, speed, and complexity.
Expanding and Compressing Text
When justifying text,
the user agent takes the remaining space
between the ends of a line’s contents and the edges of its line box,
and distributes that space throughout its content
so that the contents exactly fill the line box.
The user agent may alternatively distribute negative space,
putting more content on the line
than would otherwise fit under normal spacing conditions.
A justification opportunity is a point
where the justification algorithm may alter spacing within the text.
A justification opportunity can be provided by a single [=typographic character unit=]
(such as a [=word separator=]),
or by the juxtaposition of two [=typographic character units=].
As with controls for [[#line-break-details|soft wrap opportunities]],
whether a [=typographic character unit=] provides a [=justification opportunity=]
is controlled by the 'text-justify' value of its parent;
similarly,
whether a [=justification opportunity=] exists
between two consecutive [=typographic character units=]
is determined by the 'text-justify' value of their nearest common ancestor.
Space distributed by justification is in addition to
the spacing defined by the 'letter-spacing' or 'word-spacing' properties.
When such additional space is distributed
to a [=word separator=] [=justification opportunity=],
it is applied under the same rules as for 'word-spacing'.
Similarly, when space is distributed
to a [=justification opportunity=] between two [=typographic character units=],
should be applied under the same rules as for 'letter-spacing'.
A justification algorithm may divide [=justification opportunities=]
into different priority levels.
All [=justification opportunities=] within a given level
are expanded or compressed at the same priority,
regardless of which [=typographic character units=] created that opportunity.
For example,
if [=justification opportunities=] between two Han characters
and between two Latin letters
are defined to be at the same level
(as they are in the ''inter-character'' justification style),
they are not treated differently
because they originate from different [=typographic character units=].
It is not defined in this level
whether or how other factors
(such as font size, letter-spacing, glyph shape, position within the line, etc.)
may influence the distribution of space to [=justification opportunities=] within the line.
The UA may enable or break optional ligatures
or use other font features
such as alternate glyphs or glyph compression
to help justify the text under any method.
This behavior is not controlled by this level of CSS.
However,
UAs must not break required ligatures
or otherwise disable features required to correctly shape complex scripts.
If a [=justification opportunity=] exists within a line,
and [[#text-align-property|text alignment]] specifies full justification
(''text-align/justify'')
for that line,
it must be justified.
Handling Symbols and Punctuation
When determining [=justification opportunities=],
a [=typographic character unit=]
from the Unicode Symbols (S*) and Punctuation (P*) classes
is generally treated the same as a [=typographic letter unit=] of the same script
(or, if the character’s script property is Common,
then as a [=typographic letter unit=] of the dominant script).
However, by typographic tradition
there may be additional rules controlling the justification of symbols and punctuation.
Therefore, the UA may reassign specific characters
or introduce additional levels of prioritization
to handle [=justification opportunities=] involving symbols and punctuation.
For example, there are traditionally no [=justification opportunities=]
between consecutive
U+2014 — EM DASH,
U+2015 ― HORIZONTAL BAR,
U+2026 … HORIZONTAL ELLIPSIS,
or U+2025 ‥ TWO DOT LEADER
characters [[JLREQ]];
thus a UA might assign these characters to a “never” prioritization level.
As another example, certain full-width punctuation characters
(such as U+301A 〚 LEFT WHITE SQUARE BRACKET)
are considered to contain a [=justification opportunity=] in Japanese.
The UA might therefore assign these characters to a higher prioritization
level than the opportunities between ideographic characters.
Unexpandable Text
If the inline contents of a line cannot be stretched to the full width of the line box,
then they must be aligned as specified by the 'text-align-last' property.
(If 'text-align-last' is ''justify'',
then they must be aligned as for ''text-align/center''.)
text-align/text-align-last-empty-inline.html
Cursive Scripts
Justification must not introduce gaps
between the joined [=typographic letter units=]
of [=cursive scripts=] such as Arabic.
If it is able,
the UA may translate space distributed to [=justification opportunities=]
within a run of such [=typographic letter units=]
into some form of cursive elongation for that run.
It otherwise must assume that no [=justification opportunity=] exists
between any pair of [=typographic letter units=] in [=cursive script=]
(regardless of whether they join).
text-justify/text-justify-004.html
text-justify/text-justify-005.html
The following are examples of unacceptable justification:
Some font designs allow for the use of the tatweel character for justification.
A UA that performs tatweel-based justification
must properly handle the rules for its use.
Note that correct insertion of tatweel characters depends on context,
including the letter-combinations involved,
location within the word,
and location of the word within the line.
Minimum Requirements for ''text-justify/auto'' Justification
For ''text-justify/auto'' justification,
this specification does not define
what all of the [=justification opportunities=] are,
how they are prioritized,
or when and how multiple levels of [=justification opportunities=] interact.
However, it does require that:
Unless contraindicated by the typographic traditions
of the [=content language=]
or adjacent symbols/punctuation,
each of the following provides a [=justification opportunity=]:
[=Word separators=]
The boundary between a [=typographic character unit=]
of any [=block scripts=]
and any other [=typographic character unit=]
The boundary between a [=typographic character unit=]
of any [=clustered scripts=]
and any other [=typographic character unit=]
All [=letters=] belonging to all [=block scripts=] are treated the same,
and all [=letters=] belonging to all [=clustered scripts=] are treated the same.
For example, no distinction is made
between the justification opportunity
between a Han letter followed by another Han letter,
vs. the justification opportunity
between a Han letter followed by a Hangul letter.
CSS offers control over text spacing
via the 'word-spacing' and 'letter-spacing' properties,
which specify additional space
around [=word separators=]
or between [=typographic character units=],
respectively.
Word Spacing: the 'word-spacing' property
Name: word-spacing
Value: normal | <>
Initial: normal
Applies to: text
Inherited: yes
Percentages: N/A
Computed value: an absolute length
Animation type: by computed value type
Canonical order: n/a
inheritance.html
parsing/word-spacing-valid.html
parsing/word-spacing-invalid.html
parsing/word-spacing-computed.html
animations/word-spacing-interpolation.html
animations/word-spacing-composition.html
c541-word-sp-000.xht
c541-word-sp-001.xht
word-spacing-101.xht
word-spacing-applies-to-001.xht
word-spacing-applies-to-002.xht
word-spacing-applies-to-003.xht
word-spacing-applies-to-005.xht
word-spacing-applies-to-006.xht
word-spacing-applies-to-007.xht
word-spacing-applies-to-008.xht
word-spacing-applies-to-009.xht
word-spacing-applies-to-010.xht
word-spacing-applies-to-011.xht
word-spacing-applies-to-012.xht
word-spacing-applies-to-013.xht
word-spacing-applies-to-014.xht
word-spacing-applies-to-015.xht
word-spacing-justify-001.xht
This property specifies additional spacing
between “words”.
Values are interpreted as defined below:
normal
No additional spacing is applied.
Computes to zero.
word-spacing-100.xht
word-spacing/word-spacing-computed-001.html
<length>
Specifies extra spacing
in addition to the intrinsic inter-word spacing
defined by the font.
tab-size/tab-size-spacing-001.html
word-spacing-004.xht
word-spacing-005.xht
word-spacing-006.xht
word-spacing-007.xht
word-spacing-008.xht
word-spacing-016.xht
word-spacing-017.xht
word-spacing-018.xht
word-spacing-019.xht
word-spacing-020.xht
word-spacing-028.xht
word-spacing-029.xht
word-spacing-030.xht
word-spacing-031.xht
word-spacing-032.xht
word-spacing-040.xht
word-spacing-041.xht
word-spacing-042.xht
word-spacing-043.xht
word-spacing-044.xht
word-spacing-052.xht
word-spacing-053.xht
word-spacing-054.xht
word-spacing-055.xht
word-spacing-056.xht
word-spacing-064.xht
word-spacing-065.xht
word-spacing-066.xht
word-spacing-067.xht
word-spacing-068.xht
word-spacing-076.xht
word-spacing-077.xht
word-spacing-078.xht
word-spacing-079.xht
word-spacing-080.xht
word-spacing-088.xht
word-spacing-089.xht
word-spacing-090.xht
word-spacing-091.xht
word-spacing-092.xht
word-spacing-097.xht
word-spacing-098.xht
word-spacing-099.xht
Additional spacing is applied to each [=word separator=] left in the text
after the [[#white-space-rules|white space processing rules]] have been applied,
and should be applied half on each side of the character
unless otherwise dictated by typographic tradition.
Values may be negative, but there may be implementation-dependent limits.
word-spacing-remove-space-001.xht
word-spacing-remove-space-002.xht
word-spacing-remove-space-003.xht
word-spacing-remove-space-004.xht
word-spacing-remove-space-005.xht
word-spacing-remove-space-006.xht
word-spacing/word-spacing-negative-value-001.html
Word-separator characters
are [=typographic character units=]
whose primary purpose and general usage is to separate words.
In Unicode this includes
(but is not exhaustively defined as)
the space (U+0020),
the no-break space (U+00A0),
the Ethiopic word space (U+1361),
the Aegean word separators (U+10100,U+10101),
the Ugaritic word divider (U+1039F),
and the Phoenician word separator (U+1091F).
[[UNICODE]]
word-spacing-characters-001.xht
Note: Neither punctuation in general,
nor fixed-width spaces (such as U+3000 and U+2000 through U+200A),
are considered [=word-separator characters=],
because even though they frequently happen to separate words,
their primary purpose is not to separate words.
word-spacing-characters-002.xht
If there are no [=word-separator characters=],
or if a word-separating character has a zero advance width
(such as U+200B ZERO WIDTH SPACE)
then the user agent must not create an additional spacing between words.
word-spacing-characters-003.xht
Tracking: the 'letter-spacing' property
Name: letter-spacing
Value: normal | <>
Initial: normal
Applies to: inline boxes and text
Inherited: yes
Computed value: an absolute length
Animation type: by computed value type
Canonical order: n/a
inheritance.html
parsing/letter-spacing-valid.html
parsing/letter-spacing-invalid.html
parsing/letter-spacing-computed.html
animations/letter-spacing-interpolation.html
animations/letter-spacing-composition.html
letter-spacing/letter-spacing-nesting-003.xht
letter-spacing/letter-spacing-bidi-003.xht
letter-spacing/letter-spacing-bidi-004.xht
letter-spacing/letter-spacing-bidi-005.xht
letter-spacing/letter-spacing-200.html
letter-spacing/letter-spacing-201.html
letter-spacing/letter-spacing-203.html
letter-spacing/letter-spacing-206.html
c542-letter-sp-000.xht
c542-letter-sp-001.xht
letter-spacing-applies-to-001.xht
letter-spacing-applies-to-002.xht
letter-spacing-applies-to-003.xht
letter-spacing-applies-to-005.xht
letter-spacing-applies-to-006.xht
letter-spacing-applies-to-007.xht
letter-spacing-applies-to-008.xht
letter-spacing-applies-to-009.xht
letter-spacing-applies-to-010.xht
letter-spacing-applies-to-011.xht
letter-spacing-applies-to-012.xht
letter-spacing-applies-to-013.xht
letter-spacing-applies-to-014.xht
letter-spacing-applies-to-015.xht
This property specifies additional spacing
(commonly called tracking)
between adjacent [=typographic character units=].
Letter-spacing is applied after
[[css-writing-modes-4#text-direction|bidi reordering]]
and is in addition to [[css-fonts-3#font-kerning-prop|kerning]]
and 'word-spacing'.
[[CSS-WRITING-MODES-4]]
[[CSS-FONTS-3]]
Depending on the justification rules in effect,
user agents may further increase or decrease the space
between [=typographic character units=]
in order to [[#text-justify-property|justify text]].
letter-spacing/letter-spacing-bidi-001.html
letter-spacing/letter-spacing-bidi-004.xht
letter-spacing/letter-spacing-nesting-003.xht
letter-spacing/letter-spacing-bidi-003.xht
letter-spacing/letter-spacing-bidi-004.xht
letter-spacing/letter-spacing-bidi-005.xht
letter-spacing/letter-spacing-206.html
letter-spacing/letter-spacing-211.html
letter-spacing/letter-spacing-212.html
letter-spacing/letter-spacing-bengali-yaphala-001.html
bidi-005.xht
bidi-006.xht
bidi-007.xht
bidi-008.xht
bidi-009.xht
bidi-010.xht
bidi-text/bidi-005a.xht
bidi-text/bidi-005b.xht
bidi-text/bidi-006a.xht
bidi-text/bidi-006b.xht
bidi-text/bidi-007b.xht
bidi-text/bidi-008b.xht
bidi-text/bidi-009b.xht
bidi-text/bidi-010b.xht
text/letter-spacing-justify-001.xht
Values have the following meanings:
normal
No additional spacing is applied. Computes to zero.
letter-spacing-100.xht
<length>
Specifies additional spacing
between [=typographic character units=].
Values may be negative,
but there may be implementation-dependent limits.
tab-size/tab-size-spacing-001.html
letter-spacing-004.xht
letter-spacing-005.xht
letter-spacing-006.xht
letter-spacing-007.xht
letter-spacing-008.xht
letter-spacing-016.xht
letter-spacing-017.xht
letter-spacing-018.xht
letter-spacing-019.xht
letter-spacing-020.xht
letter-spacing-028.xht
letter-spacing-029.xht
letter-spacing-030.xht
letter-spacing-031.xht
letter-spacing-032.xht
letter-spacing-040.xht
letter-spacing-041.xht
letter-spacing-042.xht
letter-spacing-043.xht
letter-spacing-044.xht
letter-spacing-052.xht
letter-spacing-053.xht
letter-spacing-054.xht
letter-spacing-055.xht
letter-spacing-056.xht
letter-spacing-064.xht
letter-spacing-065.xht
letter-spacing-066.xht
letter-spacing-067.xht
letter-spacing-068.xht
letter-spacing-076.xht
letter-spacing-077.xht
letter-spacing-078.xht
letter-spacing-079.xht
letter-spacing-080.xht
letter-spacing-088.xht
letter-spacing-089.xht
letter-spacing-090.xht
letter-spacing-091.xht
letter-spacing-092.xht
letter-spacing-097.xht
letter-spacing-098.xht
letter-spacing-099.xht
letter-spacing-101.xht
letter-spacing-102.xht
For legacy reasons,
a computed 'letter-spacing' of zero
yields a [=resolved value=]
({{getComputedStyle()}} return value)
of ''letter-spacing/normal''.
For the purpose of 'letter-spacing',
each consecutive run of [=atomic inlines=]
(such as images and inline blocks)
is treated as a single [=typographic character unit=].
letter-spacing/letter-spacing-204.html
Letter-spacing must not be applied at the beginning of a line.
Whether letter-spacing is applied at the end of a line is undefined in this level.
letter-spacing/letter-spacing-end-of-line-001.html
tab-size/tab-size-spacing-001.html
letter-spacing/letter-spacing-200.html
letter-spacing/letter-spacing-201.html
white-space/white-space-letter-spacing-001.html
When letter-spacing is not applied at the beginning or end of a line,
text always fits flush with the edge of the block.
p { letter-spacing: 1em; }
abc
a b c
a b c
UAs therefore really should not [[RFC6919]]
append letter spacing to the right or trailing edge of a line:
a b c
Letter spacing between two [=typographic character units=]
effectively “belongs” to the innermost element
that contains the two [=typographic character units=]:
the total letter spacing between two adjacent [=typographic character units=]
(after bidi reordering)
is specified by and rendered within the innermost element
that contains the boundary
between the two [=typographic character units=].
However, the UA may instead attach letter-spacing at element boundaries
to one or the other [=typographic character unit=]
using the letter-spacing value pertaining to its containing element.
Note: This secondary behavior is permitted in this level
due to Web-compat concerns.
letter-spacing/letter-spacing-bidi-002.html
letter-spacing/letter-spacing-bidi-004.xht
letter-spacing/letter-spacing-bidi-005.xht
letter-spacing/letter-spacing-nesting-001.html
letter-spacing/letter-spacing-nesting-002.html
letter-spacing/letter-spacing-nesting-003.xht
letter-spacing/letter-spacing-203.html
letter-spacing/letter-spacing-205.html
An inline box is expected to only include
letter spacing between characters completely contained within that element,
thus excluding letter spacing on the right or trailing edge of the element:
p { letter-spacing: 1em; }
abbc
a b b c
a b b c
Consequently a given value of 'letter-spacing' is expected
to only affect the spacing between characters
completely contained within the element for which it is specified:
p { letter-spacing: 1em; }
span { letter-spacing: 2em; }
abbc
a b b c
This further implies that applying 'letter-spacing' to
an element containing only a single character
has no effect on the rendered result:
p { letter-spacing: 1em; }
span { letter-spacing: 2em; }
abc
a b c
Since letter spacing is inserted after RTL reordering,
the letter spacing applied to the inner span below likewise has no effect,
since after reordering the "c" doesn’t end up next to "א":
p { letter-spacing: 1em; }
span { letter-spacing: 2em; }
<!-- abc followed by Hebrew letters alef (א), bet (ב) and gimel (ג) -->
<!-- Reordering will display these in reverse order. -->
<p>ab<span>cא</span>בג</p>
a b cא ב ג
Letter spacing ignores invisible zero-width formatting characters
(such as those from the Unicode Cf category).
Spacing must be added as if those characters did not exist in the document.
letter-spacing/letter-spacing-control-chars-001.html
letter-spacing/letter-spacing-202.html
For example, 'letter-spacing' applied to
A​B is identical to AB,
regardless of where any element boundaries might fall.
When the effective spacing between two characters is not zero
(due to either [[#text-justify-property|justification]]
or a non-zero value of 'letter-spacing'),
user agents should not apply optional ligatures,
i.e. those that are not defined as required
for fundamentally correct glyph shaping.
However, ligatures and other font features
specified via the low-level 'font-feature-settings' property
take precedence over this rule.
See [[css-fonts-3#feature-precedence]].
letter-spacing/letter-spacing-ligatures-001.html
letter-spacing/letter-spacing-ligatures-002.html
letter-spacing/letter-spacing-ligatures-003.html
letter-spacing/letter-spacing-ligatures-004.html
For example, if the word “filial” is letter-spaced,
an “fi” ligature should not be used
as it will prevent even spacing of the text.
Note: In OpenType, required ligatures are expected
to be associated to the rlig feature.
All other ligatures are therefore considered optional.
In some cases, however, UA or platform heuristics
apply additional ligatures in order to handle broken fonts;
this specification does not define or override such exceptional handling.
Cursive Scripts
If it is able,
the UA may apply letter spacing to [=cursive scripts=]
by translating the total extra space to be distributed to a run of such letters
into some form of cursive elongation
(or compression, for negative tracking values)
for that run
that results in an equivalent total expansion (or compression) of the run.
Otherwise,
if the UA cannot expand text from a [=cursive script=]
without breaking its cursive connections,
it must not apply spacing
between any pair of that script’s [=typographic letter units=] at all
(effectively treating each word as a single [=typographic letter unit=]
for the purpose of letter-spacing).
Both cases will result in an effective spacing of zero between such letters;
however the former will preserve the sense of stretching out the text.
Below are some appropriate and inappropriate examples of spacing out Arabic text.
—
Original text
BAD
Even distribution of space between each letter.
Notice this breaks cursive joins!
OK
Distributing ∑letter-spacing
by typographically-appropriate cursive elongation.
The resulting text is as long as the previous evenly-spaced example.
OK
Suppressing 'letter-spacing' between Arabic letters.
Notice 'letter-spacing' is nonetheless applied
to non-Arabic characters (like [=spaces=]).
BAD
Applying 'letter-spacing' only between non-joined letters.
This distorts typographic color and obfuscates word boundaries.
Note: Proper cursive elongation or compression of a text
can vary depending on the
script,
typeface,
language,
location within a word,
location within a line,
implementation complexity,
font capabilities,
and calligraphic preferences,
and may not be possible in certain cases at all.
It may involve the use of shortening ligatures,
swash variants,
contextual forms,
elongation glyphs such as U+0640 ـ ARABIC TATWEEL,
or other microtypography.
It is outside the scope of CSS to define rules for these effects.
Authors should avoid applying 'letter-spacing' to cursive scripts
unless they are prepared to accept non-interoperable results.
Shaping Across Element Boundaries
Text shaping must be broken at inline box boundaries
when any of the following are true
for any box whose boundary separates the two [=typographic character units=]:
Any of 'margin'/'border'/'padding'
separating the two [=typographic character units=] in the inline axis
is non-zero.
shaping/shaping-009.html
shaping/reference/shaping-009-ref.html
shaping/shaping-010.html
shaping/reference/shaping-010-ref.html
shaping/shaping-011.html
shaping/reference/shaping-011-ref.html
boundary-shaping/boundary-shaping-003.html
boundary-shaping/boundary-shaping-004.html
boundary-shaping/boundary-shaping-005.html
boundary-shaping/boundary-shaping-007.html
boundary-shaping/boundary-shaping-009.html
'vertical-align' is not ''vertical-align/baseline''.
boundary-shaping/boundary-shaping-002.html
boundary-shaping/boundary-shaping-006.html
The boundary is a [=bidi-isolates|bidi isolation boundary=].
shaping/shaping-012.html
shaping/reference/shaping-012-ref.html
shaping/shaping-013.html
boundary-shaping/boundary-shaping-008.html
Text shaping must not be broken across inline box boundaries
when there is no effective change in formatting,
or if the only formatting changes do not affect the glyphs
(as in applying text decoration).
text-transform/text-transform-shaping-001.html
text-transform/text-transform-shaping-002.html
text-transform/text-transform-shaping-003.html
shaping/shaping-000.html
shaping/reference/shaping-000-ref.html
shaping/shaping-004.html
shaping/shaping-005.html
shaping/shaping-006.html
shaping/shaping-007.html
shaping/shaping-014.html
shaping/reference/shaping-014-ref.html
shaping/shaping-016.html
shaping/reference/shaping-016-ref.html
shaping/shaping-022.html
shaping/reference/shaping-022-ref.html
shaping/shaping-025.html
shaping/reference/shaping-025-ref.html
shaping/shaping_lig-000.html
boundary-shaping/boundary-shaping-001.html
boundary-shaping/boundary-shaping-010.html
Text shaping should not be broken across inline box boundaries otherwise,
if it is reasonable and possible for that case given the limitations of the font technology.
shaping/shaping-001.html
shaping/reference/shaping-001-ref.html
shaping/shaping-002.html
shaping/reference/shaping-002-ref.html
shaping/shaping-003.html
shaping/reference/shaping-003-ref.html
shaping/shaping-008.html
shaping/reference/shaping-008-ref.html
shaping/shaping-017.html
shaping/shaping-018.html
shaping/shaping-020.html
shaping/reference/shaping-020-ref.html
shaping/shaping-021.html
shaping/reference/shaping-021-ref.html
shaping/shaping-023.html
shaping/reference/shaping-023-ref.html
shaping/shaping-024.html
shaping/reference/shaping-024-ref.html
boundary-shaping/boundary-shaping-009.html
An example of reasonable and possible shaping across boundaries
is Arabic shaping:
in many systems this is performed by the font engine,
allowing the font to provide variant glyphs
with potentially very sophisticated contextual shaping.
It’s not generally possible to rely on this system across a font change
unless the font engine has an API to provide context,
but it is straightforward and therefore quite reasonable
for an engine to work around this limitation by, for example,
using the zero-width-joiner (U+200D) or zero-width-non-joiner (U+200C)
as appropriate to solicit the correct choice of
initial/medial/final/isolated glyph.
An example of possible but not reasonable shaping across boundaries
is handling a font that is sensitive to 20 characters of context
on either side to choose its glyphs:
passing all the text before and after the string in question,
even through multiple inline boundaries with formatting changes,
is complicated.
The UA could handle such cases,
but is not required to,
as they are not typical or fundamentally required
by any modern writing system.
An example of impossible shaping across boundaries
is a change in font weight partway through the word “and”
in a font where a ligature would replace
all three letters of the word “and”
with an ampersand glyph (“&”).
Edge Effects
Edge effects control
the indentation of lines with respect to other lines in the block ('text-indent')
and how content is measured at the start and end edges of a line ('hanging-punctuation').
First Line Indentation: the 'text-indent' property
Name: text-indent
Value: [ <> ] && hanging? && each-line?
Initial: 0
Applies to: block containers
Inherited: yes
Percentages: refers to block container’s own inline-axisinner size
Computed value: computed <> value, plus any specified keywords
Animation type: by computed value type
Canonical order: per grammar
inheritance.html
parsing/text-indent-valid.html
parsing/text-indent-invalid.html
parsing/text-indent-computed.html
animations/text-indent-interpolation.html
animations/text-indent-composition.html
text-indent/text-indent-long-line-crash.html
text-indent/anonymous-flex-item-001.html
text-indent/anonymous-grid-item-001.html
c547-indent-000.xht
c547-indent-001.xht
text-indent-012.xht
text-indent-013.xht
text-indent-014.xht
text-indent-112.xht
text-indent-applies-to-001.xht
text-indent-applies-to-002.xht
text-indent-applies-to-003.xht
text-indent-applies-to-005.xht
text-indent-applies-to-006.xht
text-indent-applies-to-007.xht
text-indent-applies-to-008.xht
text-indent-applies-to-009.xht
text-indent-applies-to-010.xht
text-indent-applies-to-011.xht
text-indent-applies-to-012.xht
text-indent-applies-to-013.xht
text-indent-applies-to-014.xht
text-indent-applies-to-015.xht
text-indent-inherited-001.xht
This property specifies the indentation
applied to lines of inline content in a block.
The indent is treated as a margin
applied to the start edge of the line box.
text-indent-010.xht
text-indent-012.xht
text-indent-013.xht
text-indent-115.xht
text-indent-on-blank-line-rtl-left-align.html
text-indent-overflow-001.xht
text-indent-overflow-002.xht
text-indent-overflow-003.xht
text-indent-overflow-004.xht
text-indent-rtl-001.xht
text-indent-rtl-002.xht
text-indent/text-indent-min-max-content-001.html
text-indent/text-indent-overflow.html
text-indent/text-indent-text-align-end.html
Unless otherwise specified
by the ''each-line'' and/or ''text-indent/hanging'' keywords,
only lines that are the
[=first formatted line=]
of an element are affected.
[[!CSS-PSEUDO-4]]
For example, the first line of an anonymous block box is only affected
if it is the first child of its parent element.
text-indent-014.xht
text-indent-wrap-001.xht
text-indent/text-indent-with-absolute-pos-child.html
Values have the following meanings:
Gives the amount of the indent
as a percentage of the block container’s own logical width.
text-indent-011.xht
text-indent-100.xht
text-indent-101.xht
text-indent-102.xht
text-indent-103.xht
text-indent-104.xht
text-indent-percent-001.xht
Percentages must be treated as ''0''
for the purpose of calculating [=intrinsic size contributions=],
but are always resolved normally when performing layout.
text-indent/percentage-value-intrinsic-size.html
text-indent/text-indent-percentage-001.xht
text-indent/text-indent-percentage-002.html
text-indent/text-indent-percentage-003.html
text-indent/text-indent-percentage-004.html
Note: This can lead to the element overflowing.
It is not recommended to use percentage indents and intrinsic sizing together.
each-line
Indentation affects the first line of each block container
and each line after a forced line break
(but not lines after a soft wrap break).
text-indent/text-indent-each-line-hanging.html
hanging
Inverts which lines are affected.
text-indent/text-indent-each-line-hanging.html
If 'text-align' is ''text-align/start'' and 'text-indent' is ''5em'' in
left-to-right text with no floats present, then first line of text
will start 5em into the block:
Since CSS1 it has been possible to
indent the first line of a block element
5em by setting the 'text-indent' property
to '5em'.
If we add the ''text-indent/hanging'' keyword,
then the first line will start flush,
but other lines will be indented 5em:
In CSS3 we can instead indent all other
lines of the block element by 5em
by setting the 'text-indent' property
to 'hanging 5em'.
Since the 'text-indent' property only affects the “first formatted line”,
a line after a forced break will not be indented.
For example, in the middle of
this paragraph is an equation,
which is centered:
x + y = z
The first line after the equation
is flush (else it would look like
we started a new paragraph).
However, sometimes (as in poetry or code),
it is appropriate to indent each line
that happens to be long enough to wrap.
In the following example, 'text-indent'
is given a value of ''3em hanging each-line'',
giving the third line of the poem a hanging indent
where it soft-wraps at the block’s right boundary:
In a short line of text
There need be no wrapping,
But when we go on and on and on
and on,
Sometimes a soft break
Can help us stay on the page.
Note: Since the 'text-indent' property inherits,
when specified on a block element, it will affect descendant
inline-block elements.
For this reason, it is often wise to specify ''text-indent: 0'' on
elements that are specified ''display: inline-block''.
Hanging Glyphs
When a glyph at the start or end edge of a line hangs,
it is not considered
when measuring the line’s contents for fit, alignment, or justification.
Depending on the line’s alignment/justification, this can
result in the mark being placed outside the line box.
The [=hanging=] glyph is also not taken into account
when computing [=intrinsic sizes=] ([=min-content size=] and [=max-content size=]),
and any sizes derived thereof.
(The interaction of this measurement and kerning is currently UA-defined;
the CSSWG welcomes advice on this point.)
white-space/full-width-leading-spaces-004.html
white-space/white-space-intrinsic-size-005.html
white-space/white-space-intrinsic-size-006.html
overflow-wrap/overflow-wrap-min-content-size-009.html
A hanging glyph
is still enclosed inside its parent inline box
and still participates in text justification:
its character advance is just not measured when determining
how much content fits on the line,
how much the line’s contents need to be expanded or compressed for justification,
or how to position the content within the line box for text alignment.
Effectively, the [=hanging=] glyph character advance
is re-interpreted as an additional negative margin
on the affected edge of its parent [=inline box=];
the line is otherwise laid out as usual.
An overflowing [=hanging glyph=] should typically be considered
[=ink overflow=]
so as to avoid creating unnecessary scrollbars,
but the UA may treat it as [=scrollable overflow=]
when the content is editable
or in other circumstances where treating it as [=scrollable overflow=]
would be useful to the user.
[[!CSS-OVERFLOW-3]]
hanging-punctuation/hanging-scrollable-001.html
white-space/white-space-intrinsic-size-019.html
white-space/white-space-intrinsic-size-020.html
hanging-punctuation/hanging-punctuation-block-bound-001.html
hanging-punctuation/hanging-punctuation-inline-bound-001.html
white-space/trailing-space-and-text-alignment-001.html
white-space/trailing-space-and-text-alignment-003.html
white-space/trailing-space-and-text-alignment-005.html
white-space/trailing-space-and-text-alignment-rtl-001.html
white-space/trailing-space-and-text-alignment-rtl-003.html
white-space/trailing-space-and-text-alignment-rtl-005.html
white-space/white-space-pre-wrap-trailing-spaces-021.html
white-space/white-space-pre-wrap-trailing-spaces-022.html
white-space/white-space-pre-wrap-trailing-spaces-023.html
text-justify/text-justify-and-trailing-spaces-001.html
text-justify/text-justify-and-trailing-spaces-002.html
text-justify/text-justify-and-trailing-spaces-003.html
text-justify/text-justify-and-trailing-spaces-004.html
text-justify/text-justify-and-trailing-spaces-005.html
text-justify/text-justify-and-trailing-spaces-006.html
In some cases, a glyph at the end of a line
can conditionally hang:
it [=hangs=] only if it does not otherwise fit in the line prior to justification.
It is not considered when measuring the line’s contents for fit;
however, any part of it that does not fit
is considered to [=hang=].
Glyphs that [=conditionally hang=] are not taken into account
when computing [=min-content sizes=]
and any sizes derived thereof,
but they are taken into account for [=max-content sizes=]
and any sizes derived thereof.
white-space/white-space-intrinsic-size-013.html
white-space/white-space-intrinsic-size-014.html
white-space/white-space-intrinsic-size-017.html
Non-zero inline-axis borders or padding between
a [=hang=]able glyph and the edge of the line prevent the glyph from hanging.
For example, a period at the end of an inline box with end padding
does not [=hang=] at the end edge of a line.
Multiple adjacent glyphs can hang together,
however specific limits on how many are allowed to hang may be specified
(e.g. at most one punctuation character may [=hang=] at each edge of the line).
Hanging Punctuation: the 'hanging-punctuation' property
Name: hanging-punctuation
Value: none | [ first || [ force-end | allow-end ] || last ]
Initial: none
Applies to: text
Inherited: yes
Canonical order: per grammar
Computed value: specified keyword(s)
Animation type: discrete
inheritance.html
parsing/hanging-punctuation-valid.html
parsing/hanging-punctuation-invalid.html
hanging-punctuation/hanging-punctuation-inline-001.html
This property determines whether a punctuation mark,
if one is present,
[=hangs=] and may be placed outside the line box (or in the indent)
at the start or at the end of a line of text.
Note: If there is not sufficient padding on the
block container, 'hanging-punctuation' can trigger overflow.
Values have the following meanings:
none
No punctuation character is made to [=hang=].
first
An opening bracket, quote, or ideographic space at the start
of the [=first formatted line=]
of an element [=hangs=].
This applies to all characters in the Unicode categories Ps, Pf, Pi
plus the ASCII quote marks U+0027 ' APOSTROPHE and U+0022 " QUOTATION MARK
and the IDEOGRAPHIC SPACE U+3000.
hanging-punctuation/hanging-punctuation-first-001.xht
hanging-punctuation/hanging-punctuation-first-002.html
last
A closing bracket or quote at the end
of the last formatted line of an element [=hangs=].
This applies to all characters in the Unicode categories Pe, Pf, Pi
plus the ASCII quote marks U+0027 ' APOSTROPHE and U+0022 " QUOTATION MARK.
hanging-punctuation/hanging-punctuation-last-001.xht
force-end
A [=stop or comma=] at the end of a line [=hangs=].
hanging-punctuation/hanging-punctuation-force-end-001.xht
allow-end
A [=stop or comma=] at the end of a line [=conditionally hangs=].
hanging-punctuation/hanging-punctuation-allow-end-001.xht
At most one punctuation character may [=hang=] at each edge of the line.
Stops and commas allowed to [=hang=] include:
U+002C
,
COMMA
U+002E
.
FULL STOP
U+060C
،
ARABIC COMMA
U+06D4
۔
ARABIC FULL STOP
U+3001
、
IDEOGRAPHIC COMMA
U+3002
。
IDEOGRAPHIC FULL STOP
U+FF0C
,
FULLWIDTH COMMA
U+FF0E
.
FULLWIDTH FULL STOP
U+FE50
﹐
SMALL COMMA
U+FE51
﹑
SMALL IDEOGRAPHIC COMMA
U+FE52
﹒
SMALL FULL STOP
U+FF61
。
HALFWIDTH IDEOGRAPHIC FULL STOP
U+FF64
、
HALFWIDTH IDEOGRAPHIC COMMA
The UA may include other characters as appropriate.
Note: The CSS Working Group would appreciate if UAs including
other characters would inform the working group
of such additions.
The ''hanging-punctuation/allow-end'' and ''force-end'' are two variations
of hanging punctuation used in East Asia.
p {
text-align: justify;
hanging-punctuation: allow-end;
}
p {
text-align: justify;
hanging-punctuation: force-end;
}
The punctuation at the end of the first line for ''hanging-punctuation/allow-end''
does not hang, because it fits without hanging.
However, if ''force-end'' is used, it is forced to hang.
The justification measures the line without the hanging punctuation.
Therefore when the line is expanded, the punctuation is pushed outside the line.
Bidirectionality and Line Boxes
The start
and end sides of a line box
are determined by the [=inline base direction=] of the line box.
Although they usually match,
the [=inline base direction=] of a [=line box=]
is distinct from the [=inline base direction=]
of the [=containing block=] or the [=bidi paragraph=].
The [=line box=]’s [=inline base direction=] affects
'text-align-all', 'text-align-last', 'text-indent', and 'hanging-punctuation'--
i.e. the position and alignment of its contents with respect to its edges.
It does not affect the formatting or ordering of inline content
(which is controlled by the Unicode Bidirectional Algorithm
as applied by CSS Writing Modes
[[!UAX9]]
[[CSS-WRITING-MODES-4]]).
In most cases, a [=line box=]’s [=inline base direction=]
is given by its [=containing block=]’s computed 'direction'.
However,
if its [=containing block=] has ''unicode-bidi: plaintext''
[[!CSS-WRITING-MODES-4]]:
If the [=bidi paragraph=] to which the [=line box=] belongs
(that is, the [=bidi paragraph=] for which the line box holds content)
has strong directionality,
the line box’s [=inline base direction=] is that direction.
bidi/bidi-lines-001.html
bidi/bidi-lines-002.html
If the [=line box=] is empty
(i.e. contains no [=atomic inlines=] or
characters other than the newline character, if any)
or otherwise has no strong directionality
(contains only weak or neutral characters),
its [=inline base direction=] is taken
from the preceding line box (if any),
or, if this is the first line box in the containing block,
from the 'direction' property of the containing block.
(This can result in an RTL line box whose contents have an LTR base direction.)
bidi/bidi-lines-002.html
In the following example,
assuming the <block>
is a start-aligned preformatted block
(''display: block; white-space: pre; text-align: start''),
every other line is right-aligned:
français
فارسی
français
فارسی
français
فارسی
Because neutral characters (such as punctuation)
and isolated runs are skipped
when finding the inline base direction of a plaintext bidi paragraph,
the line box in the following example will be left-to-right
(and thus left-aligned given ''text-align: start''),
as dictated by the first strong character, ‘h’:
“שלום!”, they said.
Because of ''unicode-bidi: plaintext'',
the “Hello!” is typeset LTR
(i.e. with the exclamation mark on the right side)
and left-aligned,
ignoring the containing block’s RTL 'direction'.
This makes the empty line following it LTR as well,
which means that a caret on that line should appear at its left edge.
The empty first line, however, is right-aligned:
having no preceding line,
it assumes the RTL direction of its containing block.
Appendix A:
Text Processing Order of Operations
This appendix is normative.
The following list defines the order of text operations.
(Implementations are not bound to this order as long as the resulting layout is the same.)
[[#white-space-phase-1|white space processing]] part I (pre-wrapping)
[=wrapping|text wrapping=] while applying per line:
* [[#text-indent-property|indentation]]
* [[css-writing-modes-4#text-direction|bidirectional reordering]] [[!CSS2]] / [[!CSS-WRITING-MODES-4]]
* [[#white-space-phase-2|white space processing]] part II
* font/glyph selection and positioning [[!CSS-FONTS-3]]
* 'letter-spacing' and 'word-spacing'
* [[#hanging-punctuation-property|hanging punctuation]]
[[#justification|justification]]
(which may affect glyph selection and/or text wrapping, looping back into that step)
[[#text-align-property|text alignment]]
letter-spacing/letter-spacing-bidi-003.xht
Appendix B:
Conversion to Plaintext
This appendix is normative for the purpose of plaintext copy-paste operations.
When a CSS-rendered document is converted to a plaintext format,
it is expected that:
The 'text-transform' property has no effect.
[[#white-space-phase-1]] is applied
and any sequence of [=collapsible=] [=white space=]
at the beginning of a [=block=]
or immediately following a [=forced line break=]
is removed.
Appendix C:
Default UA Stylesheet
This appendix is informative,
and is to help UA developers to implement a default stylesheet for HTML,
but UA developers are free to ignore or modify as appropriate.
/* make option elements align together */
option { text-align: match-parent; }
Appendix D:
Scripts and Spacing
This appendix is normative.
Typographic behavior varies somewhat by language,
but varies drastically by writing system.
This appendix categorizes some common [=Unicode script|scripts=] in Unicode 6.0
according to their justification and spacing behavior.
Category descriptions are descriptive, not prescriptive;
the determining factor is the prioritization of [=justification opportunities=].
block scripts
CJK and by extension all Wide characters
(see East Asian Width [[!UAX11]]).
The following [=Unicode scripts=] are included:
Bopomofo, Han, Hangul, Hiragana, Katakana, and Yi.
Characters of the [=East Asian Width property=]
Wide and Fullwidth are also included,
but Ambiguous characters are included
only if the [=writing system=] is
Chinese,
Korean,
or Japanese.
clustered scripts
Clustered scripts have discrete units
and break only at word boundaries,
but do not use visible word separators.
They prioritize stretching spaces,
but comfortably admit inter-character spacing for justification.
The clustered scripts include,
but are not limited to,
the following [=Unicode scripts=]:
Khmer,
Lao,
Myanmar,
New Tai Lue,
Tai Le,
Tai Tham,
Tai Viet,
Thai
cursive scripts
Cursive scripts do not admit gaps
between their letters for either justification or 'letter-spacing'.
The following [=Unicode scripts=] are included:
Arabic,
Mandaic,
Mongolian,
N’Ko,
Phags Pa,
Syriac
Note: Indic scripts with baseline connectors
(such as Devanagari and Gujarati)
are not considered [=cursive scripts=],
and do admit such gaps
between [=typographic character units=].
See Indic Layout Requirements.
[[ILREQ]]
User agents should update this list
as they update their Unicode support
to handle as-yet-unencoded cursive scripts in future versions of Unicode,
and are encouraged to ask the CSSWG to update this spec accordingly.
Appendix E:
Characters and Properties
This appendix is normative.
Unicode defines four code point-level properties
that are referenced in CSS typesetting:
Defined in Unicode Standard Annex #24 [[!UAX24]] and given as the Script property
in the Unicode Character Database
[[!UAX44]].
(UAs must include any ScriptExtensions.txt assignments in this mapping.)
Defined in Unicode Standard Annex #50 [[!UAX50]] as the Vertical_Orientation property
in the Unicode Character Database
[[!UAX44]].
Unicode defines properties for individual code points,
but sometimes it is necessary to determine the properties
of a [=typographic character unit=].
For the purposes of CSS Text,
the properties of a [=typographic character unit=] are given
by the base character of its first [=grapheme cluster=]--
except in two cases:
[=Grapheme clusters=] formed with an Enclosing Mark
(Me)
of the Common script
are considered to be Other Symbols
(So)
in the Common script.
They are assumed to have the same Unicode properties
as the replacement character (U+FFFD).
[=Grapheme clusters=] formed with a Space Separator
(Zs)
as the base
are considered to be Modifier Symbols
(Sk).
They are assumed to have the same East Asian Width property as the base,
but take their other properties
from the first combining character in the sequence.
Appendix F:
Identifying the Content Writing System
This appendix is normative.
While most languages have a preferred writing system,
some have multiple, and
most can also be transcribed into one or more foreign writing systems.
As a common example, most languages have at least one Latin transcription,
and can thus be written in the Latin writing system.
Transcribed texts typically adopt the typographic conventions of the writing system:
for example Japanese “romaji” and Chinese Pinyin use Latin letters and word spaces,
and follow Latin line-breaking and justification practices accordingly.
As another example, historical ideographic Korean
(ko-Hani)
does not use word spaces,
and should therefore be typeset similar to Chinese
rather than modern Korean.
In HTML or any other [=document language=]
using BCP47 tags for identifying languages to declare the [=content language=],
authors can disambiguate or indicate the use of an atypical writing system
with script subtags.
[[BCP47]]
For example, to indicate use of the Latin writing system
for languages which don’t natively use it,
the -Latn script subtag can be added,
e.g. ja-Latn for Japanese romaji.
Other subtags exist for other writing systems,
see ISO’s Code for the Representation of Names of Scripts and the ISO15924 script tag registry.
[[ISO15924]]
Some common/historical examples of using BCP47 tags with script subtags:
zh-Latn
Chinese, written in Latin transcription.
ko-Hani
Korean, written in Hanja (Chinese ideographic characters).
tr-Arab
Turkish, written in Arabic script.
mn-Cyrl
Mongolian, written in Cyrillic.
mn-Mong
Mongolian, written in traditional Mongolian script.
However, BCP47 script subtags are not typically used
(and are in fact discouraged)
for languages strongly associated with a single writing system:
instead that writing system is expected to be implied
when no other is specified.
[[BCP47]]
IANA maintains a database of various languages’ most common writing system
via the Suppress-Script field in its
language subtag registry
for this purpose.
Note: More advice on language tagging can be found in
the Internationalization Working Group’s
“Language tags in HTML and XML”
and “Choosing a Language Tag”.
When no writing system is explicitly indicated,
UAs should assume the most common writing system
of the declared [=content language=]
for language-sensitive typographic behaviors
such as line-breaking or justification.
However, UAs must not assume that writing system
if the author has explicitly declared a different one.
If the UA has no language-specific knowledge
of a particular language and writing system combination,
it must use the typographic conventions of the declared writing system
(assuming the conventions of a different language if necessary),
not the conventions of the declared language in an assumed writing system,
which would be inappropriate to the declared writing system.
writing-system/writing-system-font-001.html
writing-system/writing-system-text-transform-001.html
writing-system/writing-system-segment-break-001.html
writing-system/writing-system-line-break-001.html
writing-system/writing-system-line-break-002.html
The full correspondence between languages and their most common writing systems
is out of scope for this document.
However, user agents must assume at least the following:
If the [=content language=] is Chinese and the [=writing system=] is unspecified,
or for any [=content language=]
if the [=writing system=] to specified to be one of the
''Hant'',
''Hans'',
''Hani'',
''Hanb'',
or ''Bopo''
ISO script codes,
then the [=writing system=] is Chinese.
If the [=content language=] is Japanese and the [=writing system=] is unspecified,
or for any [=content language=]
if the [=writing system=] to specified to be one of the
''Jpan'',
''Hrkt'',
''Hira'',
or ''Kana'' ISO script codes,
then the [=writing system=] is Japanese.
writing-system/writing-system-line-break-002.html
writing-system/writing-system-segment-break-001.html
If the [=content language=] is Korean and the [=writing system=] is unspecified,
or for any [=content language=]
if the [=writing system=] to specified to be one of the
''Kore'',
''Hang'',
or ''Jamo''
ISO script codes,
then the [=writing system=] is Korean.
The [=writing system=] is only considered
to be unknown
if the [=content language=] itself is unknown,
or if it explicitly indicates an unknown writing system.
Note: Mere omission of the [=writing system=] information
when the [=content language=] is declared
means the that the [=writing system=] is implied, not unknown.
This specification leaks the user’s installed hyphenation and line-breaking dictionaries.
Security Considerations
This specification introduces no new security considerations.
Acknowledgements
This specification would not have been possible without the help from:
Addison Phillips,
Aharon Lanin,
Alan Stearns,
Ambrose Li,
Arnold Schrijver,
Arye Gittelman,
Ayman Aldahleh,
Ben Errez,
Bert Bos,
Chris Lilley,
Chris Pratley,
Chris Thrasher,
Chris Wilson,
Dave Hyatt,
David Baron,
Emilio Cobos Álvarez,
Eric LeVine,
Etan Wexler,
Frank Tang,
Håkon Wium Lie,
IM Mincheol,
Ian Hickson,
James Clark,
Javier Fernandez,
John Daggett,
Jonathan Kew,
Ken Lunde,
Laurie Anna Edlund,
Marcin Sawicki,
Martin Dürst,
Martin Heijdra,
Masafumi Yabe,
Masayasu Ishikawa,
Michael Jochimsen,
Michel Suignard,
Mike Bemford,
Myles Maxfield,
Nat McCully,
Paul Nelson,
Rahul Sonnad,
Richard Ishida,
Shinyu Murakami,
Stephen Deach,
Steve Zilles,
Takao Suzuki,
Tantek Çelik,
Xidorn Quan,
Yaniv Feinberg.
Changes
Recent Changes
The following normative changes have been made since
the September 2023 Candidate Recommendation:
* None yet
The following normative changes have been made since
the February 2023 Candidate Recommendation.
* Update [[#small-kana]] to Unicode 15.0.
(Issue 8442)
text-transform/text-transform-full-size-kana-008.html
* Non-tailorable Unicode line breaking controls other than NBSP
take precedence over our rule about atomic inlines.
(Issue 8972)
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 asincluding U+00A0 NO-BREAK SPACE.
However,
with the exception of U+00A0 NO-BREAK SPACE,
there must be no [=soft wrap opportunity=]
between [=atomic inlines=] and adjacent characters
belonging to the Unicode GL, WJ, or ZWJ line breaking classes.
[[UAX14]]
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-replaced-002.html
line-breaking/line-breaking-replaced-003.html
line-breaking/line-breaking-atomic-010.html
line-breaking/line-breaking-atomic-011.html
line-breaking/line-breaking-atomic-012.html
line-breaking/line-breaking-atomic-013.html
line-breaking/line-breaking-atomic-014.html
line-breaking/line-breaking-atomic-015.html
line-breaking/line-breaking-atomic-016.html
line-breaking/line-breaking-atomic-017.html
line-breaking/line-breaking-atomic-018.html
line-breaking/line-breaking-atomic-019.html
line-breaking/line-breaking-atomic-020.html
line-breaking/line-breaking-atomic-021.html
line-breaking/line-breaking-atomic-022.html
line-breaking/line-breaking-atomic-023.html
line-breaking/line-breaking-atomic-024.html
line-breaking/line-breaking-atomic-025.html
line-breaking/line-breaking-atomic-026.html
line-breaking/line-breaking-atomic-027.html
The following normative changes have been made since
the December 2020 Candidate Recommendation.
* Allow ''hanging-punctuation: first'' to hang U+300 IDEOGRAPHIC SPACE
in order to accommodate plaintext indentation habits.
(Issue 2462)
first
An opening bracket, or quote, or ideographic space at the start
of the [=first formatted line=]
of an element [=hangs=].
This applies to all characters in the Unicode categories Ps, Pf, Pi
plus the ASCII quote marks U+0027 ' APOSTROPHE and U+0022 " QUOTATION MARK
plus the ASCII quote marks U+0027 ' APOSTROPHE and U+0022 " QUOTATION MARK
and the IDEOGRAPHIC SPACE U+3000.
hanging-punctuation/hanging-punctuation-first-002.html
* Define that ''distribute'' computes to ''inter-character'', rather than merely behave the same;
allow ''text-justify/distribute'' to be implemented as a [=legacy value alias=],
since this is easier for some engines and does not matter for compatibility.
(Issue 6156,
Issue 7322)
parsing/text-justify-computed-legacy.html
* Clarify that language-specific hyphenation rules also apply to explicit [=hyphenation opportunities=].
(Issue 5973)
Words are only hyphenated where there are characters inside the word
that explicitly suggest [=hyphenation opportunities=].
The UA must use the appropriate language-specific hyphenation character(s)
and should apply any appropriate spelling changes
just as for automatic hyphenation at the same point.
hyphens/i18n/hyphens-i18n-manual-001.html
hyphens/i18n/hyphens-i18n-manual-002.html
hyphens/i18n/hyphens-i18n-manual-003.html
hyphens/i18n/hyphens-i18n-manual-004.html
hyphens/i18n/hyphens-i18n-manual-005.html
* Define ''text-align/match-parent'' on the [=root element=] to compute to ''text-align/start''
instead of computing against the [=principal writing mode=].
(Issue 6542)
text-align/text-align-match-parent-root-logical.html
* Make authoring advice regarding 'text-transform' a normative recommendation.
(Issue 8279)
Note: The 'text-transform' property only affects the presentation layer;
correct casing for semantic purposes is expected to be represented
in the source document.
Advisement: Authors must not rely on 'text-transform' for semantic purposes;
rather the correct casing and semantics should be encoded
in the source document text and markup.
In addition there have been some minor editorial fixes.