Title: CSS Text Module Level 3 Shortname: css-text Level: 3 Status: ED Work Status: Refining Group: csswg ED: https://drafts.csswg.org/css-text-3/ TR: https://www.w3.org/TR/css-text-3/ Previous Version: https://www.w3.org/TR/2018/WD-css-text-3-20181206/ Previous Version: https://www.w3.org/TR/2018/WD-css-text-3-20180920/ Previous Version: https://www.w3.org/TR/2017/WD-css-text-3-20170822/ Previous Version: https://www.w3.org/TR/2013/WD-css-text-3-20131010/ Previous Version: https://www.w3.org/TR/2012/WD-css3-text-20121113/ Issue Tracking: Tracker http://www.w3.org/Style/CSS/Tracker/products/10 Test Suite: http://test.csswg.org/suites/css3-text/nightly-unstable/ Editor: Elika J. Etemad / fantasai, Invited Expert, http://fantasai.inkedblade.net/contact, w3cid 35400 Editor: Koji Ishii, Invited Expert, kojiishi@gluesoft.co.jp, w3cid 45369 Editor: Florian Rivoal, Invited Expert, https://florian.rivoal.net, w3cid 43241 Abstract: This CSS module defines properties for text manipulation and specifies their processing model. It covers line breaking, justification and alignment, white space handling, and text transformation. At Risk: the ''full-width'' value of 'text-transform' At Risk: the ''full-size-kana'' value of 'text-transform' At Risk: the <length> values of the 'tab-size' property At Risk: the 'text-justify' property At Risk: the percentage values of 'word-spacing' At Risk: the 'hanging-punctuation' property At Risk: the ''line-break/anywhere'' value of the 'line-break' property Ignored Vars: letter-spacing Status Text: This publication partially addresses the issues in the disposition of comments since the October 2013 Last Call Working Draft, and, while a marked improvement over the previous draft, is not considered to be entirely up-to-date at the time of publication. A completed dispostion of comments and corresponding draft will be published once the issues are fully addressed and reviewed by the CSSWG and Internationalization WG. WPT Path Prefix: /css/css-text/
spec:css-display-3; type:property; text:display spec:css-fonts-4; type:property; text:font-feature-settings
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 case transformation, white space collapsing, text wrapping, line breaking rules and hyphenation, alignment and justification, spacing, and indentation.
Note: Font selection is covered in CSS Fonts Level 3 [[CSS-FONTS-3]].
Features for decorating text, such as underlines, emphasis marks, and shadows, (previously part of this module) are covered in CSS Text Decoration Level 3 [[CSS-TEXT-DECOR-3]].
Bidirectional and vertical text are addressed in CSS Writing Modes Level 3 [[CSS-WRITING-MODES-3]].
This module, together with [[CSS-TEXT-DECOR-3]], replaces and extends the text-level features defined in [[!CSS2]] chapter 16.
In addition to the terms defined below,
other terminology and concepts used in this specification are defined
in [[!CSS2]] and [[!CSS-WRITING-MODES-3]].
Authors should language-tag their content accurately for the best typographic behavior.
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.
For example, the rules for determining the content language of an HTML
are defined in [[HTML]],
and the rules for determining the content language of an XML element use
are defined in [[XML10]].
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 tag content using the global lang
attribute in HTML,
the universal xml:lang
attribute in XML,
and the HTTP Content-Language
header for content served over HTTP.
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.
Note: Depending on the [=document language=]'s facilities for identifying the [=content language=],
information about the [=writing system=] may only be carried implicitly.
That is typically the case with the [[BCP47]] language tag used in [[HTML]],
although it can optionally indicate the [=writing system=] explicitly
using a script subtag.
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.
More information about language tags and their interpretation,
particularly the use of script tags for atypical language + writing-system combinations,
can be found in [[#script-tagging]].
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 behaviour 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.).
Note: The rules for such tailorings are out of scope for CSS.
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 [[!UAX29]] grapheme cluster.
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 [[!UAX29]] grapheme cluster, and may require decomposition or other substitutions before spacing can be inserted.
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 [[!CSS-WRITING-MODES-3]] can also require tailoring. For example, when typesetting ''text-orientation/upright'' text, Tibetan tsek and shad marks are kept with the preceding grapheme cluster, rather than treated as an independent typographic character unit.
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 in Unicode. [[!UAX44]] 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 by element boundaries may give inconsistent or undesired results.
Name: text-transform Value: none | [capitalize | uppercase | lowercase ] || full-width || full-size-kana Initial: none Applies to: inline boxes Inherited: yes Canonical order: n/a Computed value: specified keyword Animation type: discrete
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.
Values have the following meanings:
For ''capitalize'', what constitutes a “word“ is UA-dependent;
[[!UAX29]] is suggested (but not required)
for determining such word boundaries.
Authors should not expect ''capitalize'' to follow
language-specific titlecasing conventions
(such as skipping articles in English).
Out-of-flow elements and inline element boundaries
must not introduce a 'text-transform' word boundary
and must be ignored when determining such word boundaries.
The following example converts the ASCII characters used in abbreviations in Japanese text to their fullwidth variants so that they lay out and line break like ideographs:
abbr:lang(ja) { text-transform: full-width; }
Note: As defined in Text Processing Order of Operations, transforming text affects line-breaking and other formatting operations.
The UA must use the full case mappings for Unicode
characters, including any conditional casing rules, as defined in
Default Case Algorithm section of The Unicode Standard [[!UNICODE]].
If (and only if) the 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.
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 undotted/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.
The definition of fullwidth and halfwidth forms can be found on the
Unicode consortium web site at [[!UAX11]].
The mapping to fullwidth form is defined by taking code points with
the <wide>
or the <narrow>
tag
in their Decomposition_Mapping
in [[!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.
The mappings for small Kana to full-size Kana are defined in [[#small-kana]].
When multiple values are specified and therefore multiple transformations need to be applied, they are applied in the following order:
Text transformation happens after white space processing, which means that ''full-width'' only transforms U+0020 spaces to U+3000 within preserved white space.
Note: A future level of CSS may introduce the ability to create custom mapping tables for less common text transforms, such as by an ''@text-transform'' rule similar to ''@counter-style'' from [[CSS-COUNTER-STYLES-3]].
Name: white-space Value: normal | pre | nowrap | pre-wrap | break-spaces | pre-line Initial: normal Applies to: inline boxes Inherited: yes Canonical order: n/a Computed value: specified keyword Animation type: discrete
This property specifies two things:
Values have the following meanings, which must be interpreted according to the White Space Processing and Line Breaking rules:
Note: This value does not guarantee that there will never be any overflow due to spaces: for example, if the line length is so short that even a single space does not fit, overflow is unavoidable.
White space that was not removed or collapsed due to white space processing is called preserved white space. In general, preserved white space is measured when calculating the intrinsic sizes of text; however preserved white space that would be allowed to hang at the end of the line (i.e. that preserved by ''pre-wrap'') is excluded-- that is, considered to hang-- when calculating min-content sizes and any sizes derived thereof.
The following informative table summarizes the behavior of various 'white-space' values:
New Lines | Spaces and Tabs | Text Wrapping | End-of-line spaces | |
---|---|---|---|---|
''white-space/normal'' | Collapse | Collapse | Wrap | Remove |
''pre'' | Preserve | Preserve | No wrap | Preserve |
''nowrap'' | Collapse | Collapse | No wrap | Remove |
''pre-wrap'' | Preserve | Preserve | Wrap | Hang |
''break-spaces'' | Preserve | Preserve | Wrap | Wrap |
''pre-line'' | Preserve | Collapse | Wrap | Remove |
See White Space Processing Rules for details on how white space collapses. An informative summary of collapsing (''white-space/normal'' and ''nowrap'') is presented below:
See Line Breaking for details on wrapping behavior.
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 interprets white space characters only for rendering: it has no effect on the underlying document data.
White space processing in CSS is controlled with the 'white-space' property.
CSS does not define document segmentation rules. Segments can be
separated by a particular newline sequence (such as a line feed or
CRLF pair), or delimited by some other mechanism, such as the SGML
RECORD-START
and RECORD-END
tokens.
For CSS processing, each document language–defined segment break
and 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.
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]] section 9.2.2.1
Control characters (Unicode category Cc
)--
other than tabs (U+0009), line feeds (U+000A),
and sequences that form a segment break--
must be rendered as a visible glyph
which the UA must synthethize if the glyphs found in the font are not visible,
and must be otherwise treated as any other character
of the Other Symbols (So
) general category and Common 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 rendering.
White space processing in CSS affects only
the document white space characters:
spaces (U+0020), tabs (U+0009), and segment breaks.
Note: The set of characters considered document white space (part of the document content) and that 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.
For each inline (including anonymous inlines;
see [[CSS2]] section 9.2.2.1)
within an inline
formatting context, white space characters are handled as follows,
ignoring bidi formatting characters
(characters with the Bidi_Control
property [[!UAX9]])
as if they were not there:
If 'white-space' is set to ''white-space/normal'', ''nowrap'', or ''pre-line'', white space characters are considered collapsible and are processed by performing the following steps:
If 'white-space' is set to ''pre'' or ''pre-wrap''
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 the sequence.
In the case of ''break-spaces'',
a soft wrap opportunity exists after every space.
Then, the entire block is rendered. Inlines are laid out, taking bidi reordering into account, and wrapping as specified by the 'white-space' property.
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:
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:
A BC
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.
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).
For other values of 'white-space', segment breaks are collapsible.
Any collapsible segment break immediately following another collapsible segment break
is removed.
Then any remaining segment break is
either transformed into a space (U+0020) or removed
depending on the context before and after the break:
Fullwidth
, Wide
, or Halfwidth
(not Ambiguous
),
and neither side is Hangul,
then the segment break is removed.
Ambiguous
,
and the character on the other side of the segment break is
Fullwidth
, Wide
, or Halfwidth
,
and not Hangul,
then the segment break is removed.
For this purpose,
Emoji (Unicode property Emoji
)
with an East Asian Width property of
Wide
or Neutral
are treated as having an East Asian Width property of
Ambiguous
.
Note: The white space processing rules have already removed any tabs and spaces after the segment break before these checks take place.
Here is an English paragraph that is broken into multiple lines in the source code so that it can more easily read in a text editor.
Here is an English paragraph that is broken into multiple lines in the source code so that it can be more easily read in a text editor.
这个段落是呢么长, 在一行写不行。最好 用三行写。
这个段落是呢么长,在一行不行。最好用三行写。
Comments on how well these rules would work in practice would be very much appreciated, particularly from people who work with Thai and similar scripts. Note that browser implementations do not currently follow these rules consistently (although IE does in some cases transform the break, and Firefox follows the first two bullet points).
As each line is laid out,
p {
white-space: pre-wrap;
text-align: end;
width: 20ch;
border: solid 1px;
}
<p>Lorem ipsum </p>
As the preserved spaces at the end of the line 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.
The sample above would therefore be rendered as follows:
Lorem ipsum
Name: tab-size Value: <> | < > Initial: 8 Applies to: block containers Inherited: yes Computed value: the specified number or absolute length Animation type: by computed value type Canonical order: n/a
This property determines the tab size used to render preserved tab characters (U+0009).
A < 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.
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.
While CSS does not fully define where soft wrap opportunities occur,
some controls are provided to distinguish common variations:
Note: Further information on line breaking conventions can be found in
[[JLREQ]] and [[JIS4051]] for Japanese,
[[CLREQ]] and [[ZHMARK]] for Chinese, and
in [[!UAX14]] for all scripts in Unicode.
See also the
Internationalization Working Group’s
Typography Index [[TYPOGRAPHY]]
which includes more information on additional languages.
Any guidance for additional appropriate references
would be much appreciated.
When determining line breaks:
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
(and/or non-letter typographic character units
belonging to the
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''.
An example of English text embedded in Japanese
being broken at an arbitrary point in the word.
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'').
Note: To enable additional break opportunities only in the case of overflow,
see 'overflow-wrap'.
Values have the following meanings: 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:
The break-points are determined as follows (indicated by ‘·’):
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 not broken
(see [[#word-break-shaping]]).
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.
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:
The rules here are following guidelines from KLREQ for Korean,
which don't allow the Chinese/Japanese-specific breaks.
However, the resulting behavior could use some review and feedback to make sure they are correct,
particularly when “word basis” breaking is used (''word-break: keep-all'') in Korean.
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: 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.
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
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 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.
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.
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 intrinsic sizes.
This property controls whether hyphenation is allowed to create more
soft wrap opportunities within a line of text.
Values have the following meanings:
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.
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.
Authors should correctly tag their content’s language
(e.g. using the 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 not broken
(see [[#word-break-shaping]]).
For example, if the Uyghur word “داميدى”
were hyphenated, it would appear as
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: For legacy reasons, UAs must treat 'word-wrap' as an [=legacy name alias=]
of the 'overflow-wrap' property.
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.
Alignment and justification controls how inline content is distributed within a line box.
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:
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
viewport
or containing block.
In the case of ''justify'', the UA may stretch or shrink any inline boxes
by 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 processing rules.
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 Bidirectionality and line boxes
for details on how to determine the start and end edges of a line box.
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.
This property describes how the last line of a block or a line
right before a forced line break is aligned.
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 start-aligned.
All other values are interpreted as described for 'text-align'.
This property selects the justification method used when a line's
alignment is set to ''justify'' (see 'text-align').
The property applies to inlines,
but is inherited from block containers to the root inline box containing their inline-level contents.
It takes the following values:
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 [[JLREQ]] for Japanese,
using cursive elongation for Arabic,
using ''inter-word'' for German,
etc.
An example of cursively-justified Arabic text,
rendered by Tasmeem.
Like English, Arabic can be justified by adjusting the spacing between words,
but in most styles it can also be justified by calligraphically elongating or compressing the letterforms themselves.
In this example, the upper text is extended to fill the line by the use of elongated (kashida) forms and swash forms,
while the bottom line is compressed slightly by using a stacked combination for the characters between ت and م.
By employing traditional calligraphic techniques,
a typesetter can justify the line while preserving flow and color,
providing a very high quality justification effect.
However, this is by its nature a very script-specific effect.
Mixed-script text with ''text-justify: auto'':
this interpretation uses a universal-compromise justification method,
expanding at spaces as well as between CJK and Southeast Asian letters.
This effectively uses inter-word + inter-ideograph spacing
for lines that have word-separators and/or CJK characters
and falls back to inter-cluster behavior for lines that don't
or for which the space stretches too far.
Mixed-script text with ''text-justify: none''
Note: This value is intended for use in user stylesheets
to improve readability or for accessibility purposes.
Mixed-script text with ''text-justify: inter-word''
Mixed-script text with ''text-justify: inter-character''
Since optimal justification is 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.
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 contents 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 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 an justification opportunity between
two typographic character units,
it is 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 alignment specifies
full justification (''text-align/justify'') for that line,
it must be justified.
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 fullwidth 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.
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 ''center''.)
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).
The following are examples of unacceptable justification:
Adding gaps between every pair of Arabic letters
Adding gaps between every pair of unjoined Arabic letters
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.
For 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
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.
This property specifies additional spacing
between “words”.
Missing values are assumed to be ''word-spacing:normal''.
Values are interpreted as defined below:
Additional spacing is applied to each word separator
left in the text after the 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-separator characters
are typographic character units whose purpose and general usage is to separate words.
In [[UNICODE]] this includes
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).
If there are no word-separator characters, or if a word-separating
character has a zero advance width (such as the zero width space U+200B)
then the user agent must not create an additional spacing between words.
General punctuation and fixed-width spaces (such as U+3000 and U+2000
through U+200A) are not considered word-separator characters. This property specifies additional spacing (commonly called tracking)
between adjacent typographic character units.
Letter-spacing is applied after
bidi reordering [[CSS-WRITING-MODES-3]]
and kerning [[CSS-FONTS-3]]
and is in addition to any 'word-spacing'.
Depending on the justification rules in effect,
user agents may further increase or decrease the space between typographic character units
in order to justify text.
Values have the following meanings:
For legacy reasons,
a computed 'letter-spacing' of zero
yields a resolved value ( 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 must not be applied at the beginning or at the end of a line.
Because letter-spacing is not applied at the beginning or end of a line,
text always fits flush with the edge of the block.
a b c a b c UAs therefore must not 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.
A given value of 'letter-spacing' only affects the spacing
between characters completely contained within the element for which it is specified:
a b b c This also means that applying 'letter-spacing' to
an element containing only a single character
has no effect on the rendered result:
a b c An inline box only includes
letter spacing between characters completely contained within that element:
a b b c It is incorrect to include the letter spacing on the right or trailing edge of the element:
a b b c Letter spacing is inserted after RTL reordering,
so the letter spacing applied to the inner span below has no effect,
since after reordering the "c" doesn't end up next to "א":
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.
For example, 'letter-spacing' applied to
When the effective spacing between two characters is not zero
(due to either 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]].
filial vs filial
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.
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').
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.
Unless otherwise specified by the ''each-line'' and/or hanging keywords,
only lines that are the
first formatted line [[!CSS2]]
of an element are affected.
For example, the first line of an anonymous block box is only affected
if it is the first child of its parent element.
Values have the following meanings: If 'text-align' is ''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: If we add the ''text-indent/hanging'' keyword,
then the first line will start flush,
but other lines will be indented 5em:
Since the 'text-indent' property only affects the “first formatted line”,
a line after a forced break will not be indented.
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:
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'. 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. When a punctuation mark 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 interaction of this measurement and kerning is currently UA-defined;
the CSSWG welcomes advice on this point.)
Values have the following meanings: Non-zero inline-axis borders or padding between
a hangable mark and the edge of the line prevent the mark 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.
At most one punctuation character may hang at each edge of the line.
A hanging punctuation mark
is still enclosed inside its parent inline box,
is still counted as part of the scrollable overflow region [[!CSS-OVERFLOW-3]],
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 punctuation mark’s 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.
Stops and commas allowed to hang include:
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 ''allow-end'' and ''force-end'' are two variations of
hanging punctuation used in East Asia. The punctuation at the end of the first line for ''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. The start and end edges of a line box
are determined by the inline base direction of the line box.
In most cases, this is given by its containing block's computed 'direction'.
However if its containing block has ''unicode-bidi: plaintext'' [[!CSS-WRITING-MODES-3]],
the line box's inline base direction must be determined
by the inline base direction of the bidi paragraph to which it belongs:
that is, the bidi paragraph for which the line box holds content.
An empty line box
(i.e. one that contains no atomic inlines or
characters other than the line-breaking character, if any),
takes its inline base direction from the preceding line box (if any), or,
if this is the first line box in the containing block,
then from the 'direction' property of the containing block.
In the following example, assuming the Note: The inline base direction determined here
applies to the line box itself, and not to its contents.
It 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 its content.
In the following example:
The result should be a left-aligned line looking like this:
The line is left-aligned
(despite the containing block having ''direction: rtl'')
because the containing block (the As expected, the "Hello!" should be displayed LTR
(i.e. with the exclamation mark on the right end,
despite the 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.)
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:
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.
If you find any issues, recommendations to add, or corrections,
please send the information to www-style@w3.org
with [css-text] in the subject line. This appendix is normative. Typographic behavior varies somewhat by language, but varies drastically by writing system.
This appendix categorizes some common 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.
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.
Should block and cluster scripts be merged?
They have different tolerances for space-justification vs inter-character justification,
but both admit both.
Unicode defines four code point-level properties that are referenced
in CSS typesetting:
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:
This appendix is normative. This specification would not have been possible without the help from:
Ayman Aldahleh, Bert Bos, Tantek Çelik, James Clark, Emilio Cobos Álvarez, Stephen Deach, John Daggett,
Martin Dürst,
Laurie Anna Edlund, Ben Errez, Yaniv Feinberg, Arye Gittelman, Ian
Hickson, Martin Heijdra, Richard Ishida, Masayasu Ishikawa,
Michael Jochimsen, Eric LeVine, Ambrose Li, Håkon Wium Lie, Chris Lilley,
Ken Lunde, Myles Maxfield, Nat McCully, IM Mincheol, Shinyu Murakami, Paul Nelson,
Chris Pratley, Xidorn Quan, Marcin Sawicki,
Arnold Schrijver, Rahul Sonnad, Alan Stearns, Michel Suignard, Takao Suzuki,
Frank Tang, Chris Thrasher, Etan Wexler, Chris Wilson, Masafumi Yabe
and Steve Zilles.
Line Breaking and Word Boundaries
Line Breaking Details
ID
[[!UAX14]]),
and additionally, for Web-compatibility, introduces a soft wrap opportunity
between itself and any adjacent U+00A0 NO-BREAK SPACE character.
Breaking Rules for Letters: the 'word-break' property
Name: word-break
Value: normal | keep-all | break-all | break-word
Initial: normal
Applies to: inline boxes
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
NU
, AL
, AI
, or ID
Unicode line breaking classes [[!UAX14]]).
It does not affect rules governing the soft wrap opportunities
created by spaces (including U+3000 IDEOGRAPHIC SPACE) and around punctuation.
(See 'line-break' for controls affecting punctuation and small kana.)
각 줄의 마지막에 한글이 올 때 줄 나눔 기
준을 “글자” 또는 “어절” 단위로 한다.
각 줄의 마지막에 한글이 올 때 줄 나눔
기준을 “글자” 또는 “어절” 단위로 한다.
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.
This option is used mostly 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.
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.
这是一些汉字 and some Latin و کمی خط عربی และตัวอย่างการเขียนภาษาไทย
这·是·一·些·汉·字·and·some·Latin·و·کمی·خط·عربی·และ·ตัวอย่าง·การเขียน·ภาษาไทย
这·是·一·些·汉·字·a·n·d·s·o·m·e·L·a·t·i·n·و·ﮐ·ﻤ·ﻰ·ﺧ·ﻁ·ﻋ·ﺮ·ﺑ·ﻰ·แ·ล·ะ·ตั·ว·อ·ย่·า·ง·ก·า·ร·เ·ขี·ย·น·ภ·า·ษ·า·ไ·ท·ย
这是一些汉字·and·some·Latin·و·کمی·خط·عربی·และ·ตัวอย่าง·การเขียน·ภาษาไทย
Line Breaking Strictness: the 'line-break' property
Name: line-break
Value: auto | loose | normal | strict | anywhere
Initial: auto
Applies to: inline boxes
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
CJ
.
(See LineBreak.txt in [[!UNICODE]].)
‐ U+2010, – U+2013, 〜 U+301C,
゠ U+30A0
々 U+3005, 〻 U+303B, ゝ U+309D,
ゞ U+309E, ヽ U+30FD, ヾ U+30FE
IN
.
(See LineBreak.txt in [[!UNICODE]].)
・ U+30FB,
: U+FF1A, ; U+FF1B, ・ U+FF65,
‼ U+203C,
⁇ U+2047, ⁈ U+2048, ⁉ U+2049,
! U+FF01, ? U+FF1F
Characters with the Unicode Line Break property PO
and the East Asian Width property [[!UAX11]]
Ambiguous
, Fullwidth
, or Wide
.
Characters with the Unicode Line Break property PR
and the East Asian Width property [[!UAX11]]
Ambiguous
, Fullwidth
, or Wide
.
Hyphenation: the 'hyphens' property
Name: hyphens
Value: none | manual | auto
Initial: manual
Applies to: inline boxes
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
ex­ample
lang
attribute
or the HTTP Content-Language
header)
in order to obtain correct automatic hyphenation.
not as
Overflow Wrapping: the 'overflow-wrap'/'word-wrap' property
Name: overflow-wrap, word-wrap
Value: normal | break-word | anywhere
Initial: normal
Applies to: inline boxes
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
Shaping Across Intra-word Breaks
Alignment and Justification
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
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
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
Justification Method: the 'text-justify' property
Name: text-justify
Value: auto | none | inter-word | inter-character
Initial: auto
Applies to: inline boxes
Inherited: yes
Canonical order: n/a
Computed value: specified keyword
Animation type: discrete
Expanding and Compressing Text
Handling Symbols and Punctuation
Unexpandable Text
Cursive Scripts
Minimum Requirements for ''text-justify/auto'' Justification
Further information on text justification can be found in (or submitted to) “Approaches to Full Justification”,
which indexes by writing system and language,
and is maintained by the W3C Internationalization Working Group. [[JUSTIFY]]
Spacing
Word Spacing: the 'word-spacing' property
Name: word-spacing
Value: normal | <
Tracking: the 'letter-spacing' property
Name: letter-spacing
Value: normal | <
getComputedStyle()
return value)
of ''letter-spacing/normal''.
p { letter-spacing: 1em; }
<p>abc</p>
p { letter-spacing: 1em; }
span { letter-spacing: 2em; }
<p>a<span>bb</span>c</p>
p { letter-spacing: 1em; }
span { letter-spacing: 2em; }
<p>a<span>b</span>c</p>
p { letter-spacing: 1em; }
<p>a<span>bb</span>c</p>
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
is identical to AB
,
regardless of where any element boundaries might fall.
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
—
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.
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.
* 'vertical-align' is not ''vertical-align/baseline''.
* The boundary is a bidi isolation boundary.
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).
Edge Effects
First Line Indentation: the 'text-indent' property
Name: text-indent
Value: [ <
Since CSS1 it has been possible to
indent the first line of a block element
5em by setting the 'text-indent' property
to '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'.
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).
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.
Hanging Punctuation: the 'hanging-punctuation' property
Name: hanging-punctuation
Value: none | [ first || [ force-end | allow-end ] || last ]
Initial: none
Applies to: inline boxes
Inherited: yes
Canonical order: per grammar
Computed value: specified keyword(s)
Animation type: discrete
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
p {
text-align: justify;
hanging-punctuation: allow-end;
}
p {
text-align: justify;
hanging-punctuation: force-end;
}
Bidirectionality and Line Boxes
<block>
is a preformatted block (''display: block; white-space: pre'') inheriting
''text-align: start'', every other line is right-aligned:
<block style="unicode-bidi: plaintext">
Latin
و·کمی
Latin
و·کمی
Latin
و·کمی
</block>
<para style="display: block; direction: rtl; unicode-bidi:plaintext">
<quote style="unicode-bidi:plaintext">שלום!</quote>", he said.
</para>
"!שלום", he said.
<para>
) has ''unicode-bidi:plaintext'',
and the line box belongs to a bidi paragraph that is LTR.
This is because that paragraph's first character with a strong direction
is the LTR "h" from "he". The RTL "שלום!" does precede the "he",
but it sits in its own bidi-isolated paragraph that is not
immediately contained by the <para>
,
and is thus irrelevant to the line box's alignment.
From from the standpoint of the bidi paragraph immediately contained
by the <para>
containing block,
the <quote>
’s bidi-isolated paragraph inside it is,
by definition, just a neutral U+FFFC character,
so the immediately-contained paragraph becomes LTR by virtue
of the "he" following it.
<fieldset style="direction: rtl">
<textarea style="unicode-bidi:plaintext">
Hello!
</textarea>
</fieldset>
<textarea>
’s ''direction:rtl'')
and left-aligned.
This makes the empty line following it left-aligned as well,
which means that the caret on that line should appear at its
left edge. The first empty line, on the other hand, should
be right-aligned, due to the RTL direction of its containing
paragraph, the <textarea>
.
Appendix A:
Text Processing Order of Operations
Appendix B: Conversion to Plaintext
Appendix C: Default UA Stylesheet
/* make list items and option elements align together */
li, option { text-align: match-parent; }
Appendix D: Scripts and Spacing
Wide
and Fullwidth
are also included,
but Ambiguous
characters are included only if
the writing system is
Chinese, Korean, or Japanese.
Appendix E.
Characters and Properties
East_Asian_Width
property
in the Unicode Character Database [[!UAX44]].
General_Category
property
in the Unicode Character Database [[!UAX44]].
Script
property
in the Unicode Character Database [[!UAX44]].
(UAs must include any ScriptExtensions.txt assignments in this mapping.)
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.
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.
Tagging Content by Writing System
ko-Hani
)
does not use word spaces,
and should therefore be typeset as for Chinese.
In [[HTML]] or any other document language using [[BCP47]] to identify the [=content language=],
authors can indicate the use of an atypical writing system
with script subtags.
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 [[BCP47]], [[ISO15924]], and the ISO15924 script tag registry.
Some common/historical examples follow:
zh-Latn
ko-Hani
tr-Arab
mn-Cyrl
mn-Mong
Appendix G.
Small Kana Mappings
Small
Full-size
ぁ U+3041
あ U+3042
ぃ U+3043
い U+3044
ぅ U+3045
う U+3046
ぇ U+3047
え U+3048
ぉ U+3049
お U+304A
ゕ U+3095
か U+304B
ゖ U+3096
け U+3051
っ U+3063
つ U+3064
ゃ U+3083
や U+3084
ゅ U+3085
ゆ U+3086
ょ U+3087
よ U+3088
ゎ U+308E
わ U+308F
ァ U+30A1
ア U+30A2
ィ U+30A3
イ U+30A4
ゥ U+30A5
ウ U+30A6
ェ U+30A7
エ U+30A8
ォ U+30A9
オ U+30AA
ヵ U+30F5
カ U+30AB
ㇰ U+31F0
ク U+30AF
ヶ U+30F6
ケ U+30B1
ㇱ U+31F1
シ U+30B7
ㇲ U+31F2
ス U+30B9
ッ U+30C3
ツ U+30C4
ㇳ U+31F3
ト U+30C8
ㇴ U+31F4
ヌ U+30CC
ㇵ U+31F5
ハ U+30CF
ㇶ U+31F6
ヒ U+30D2
ㇷ U+31F7
フ U+30D5
ㇸ U+31F8
ヘ U+30D8
ㇹ U+31F9
ホ U+30DB
ㇺ U+31FA
ム U+30E0
ャ U+30E3
ヤ U+30E4
ュ U+30E5
ユ U+30E6
ョ U+30E7
ヨ U+30E8
ㇻ U+31FB
ラ U+30E9
ㇼ U+31FC
リ U+30EA
ㇽ U+31FD
ル U+30EB
ㇾ U+31FE
レ U+30EC
ㇿ U+31FF
ロ U+30ED
ヮ U+30EE
ワ U+30EF
ァ U+FF67
ア U+FF71
ィ U+FF68
イ U+FF72
ゥ U+FF69
ウ U+FF73
ェ U+FF6A
エ U+FF74
ォ U+FF6B
オ U+FF75
ッ U+FF6F
ツ U+FF82
ャ U+FF6C
ヤ U+FF94
ュ U+FF6D
ユ U+FF95
ョ U+FF6E
ヨ U+FF96
Privacy and Security Considerations
This specification introduces no new security considerations.
This specification leaks the user's installed hyphenation and line-breaking dictionaries.
Acknowledgements
Changes
Changes from the 12 December 2018 Working Draft
* Clarify that ''hyphens: none'' does not suppress wrapping opportunities after U+002D or U+2010.
* Fix stray text leftover when removing percentages as a possible value for word-spacing.
* Add support for ''word-break: break-word'' as a deprecated value, as needed for compatibility with this previously proprietary syntax.
* Use ''allow-end'' hanging rules rather than ''force-end'' rules for trailing white space;
define how it impacts intrinsic size contributions of text.
(Issue 3440)
Changes from the 6 December 2018 Working Draft
Changes between 6 December 2018 and 12 December 2018 consist of
some minor cleanup in the line breaking section
and deferring <
Changes from the October
2013 CSS3 Text LCWD
ISSUE: THIS CHANGES LIST IS WAY INCOMPLETE PLEASE SEE
Disposition of Comments.