Copyright ©2002 W3C® (MIT, INRIA, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply.
This document presents a set of text formatting properties for CSS3. Many of these properties already existed in CSS 2 [CSS2]. Many of the new properties have been added to address basic requirements in international text layout, particularly for East Asian and bidirectional text.
This document is a working draft of the CSS working group which is part of the Style activity. It contains a proposal for features to be included in CSS level 3.
This is the last call for comments, before the working group will decide if the draft is ready for Candidate Recommendation. The deadline for comments is 27 November 2002.
Feedback is very much welcome. Comments can be sent directly to the editor, but the mailing list www-style@w3.org (see instructions) is also open and is preferred for discussion of this and other drafts in the Style area. The mailing list is archived.
This document has been produced as a combined effort of the W3C Internationalization Activity, and the Style Activity. It also includes extensive contribution made by members of the XSL Working Group (members only). Finally, some of the proposal surfaced first in the Scalable Vector Graphics (SVG) 1.0 Specification [SVG1.0]. The text has been duplicated in this document to reflect which properties and specification should eventually be referenced in CSS itself.
This working draft may be updated, replaced or rendered obsolete by other W3C documents at any time. It is inappropriate to use W3C Working Drafts as reference material or to cite them as other than "work in progress". Its publication does not imply endorsement by the W3C membership or the CSS Working Group (members only).
Patent disclosures relevant to CSS may be found on the Working Group's public patent disclosure page.
To find the latest version of this working draft, please follow the "Latest version" link above, or visit the list of W3C Technical Reports.
This CSS3 module depends on the following other CSS3 modules:
It has non-normative (informative) references to the following other CSS3 modules:
In both CSS1 and CSS2, text formatting has been limited to simple effects like for example: text decoration, text alignment and character spacing. However, International typography contains types of formatting that could not be achieved without using special workarounds or graphics.
Along with already existing text related properties, this document presents a number of new CSS properties to represent such formatting. For example, the features this proposal covers include two of the most important features for East Asian typography: vertical text and layout grid.
There is a number of illustrations in this document for which the following legend is used:
- wide-cell glyph (e.g. Han)
which is the n-th character in the text run,
- narrow-cell glyph (e.g. Roman)
which is the n-th glyph in the text run,
- connected glyph (e.g. Arabic)
which is the n-th glyph in the text run.
Many typographical properties in East Asian typography depends on the fact that a character is typically rendered as either a wide or narrow character. All characters described by the Unicode Standard [UNICODE] can be categorized by a width property. This is covered by the Unicode Standard Annex [UAX-11].
The orientation which the above symbols assume in the diagrams corresponds to the orientation that the glyphs they represent are intended to assume when rendered in the UA (user agent). Spacing between these characters in the diagrams is usually symbolic, unless intentionally changed to make a point.
Furthermore, all properties, in addition to the noted values, take 'initial' and 'inherit'. These values are not repeated in each of the property value enumeration.
This module uses extensively the 'before', 'after', 'start' and 'end' notation to specify the four edges of a box relative to its text advance direction, independently of its absolute positioning in terms of 'top', 'bottom', 'left' and 'right' (corresponding respectively to the 'before', 'after', 'start' and 'end' positions in a typical Western text layout). This notation is also used extensively in [XSL1.0] for the same purpose.
Finally, in this document, requirements are expressed using the key words "MUST", "MUST NOT", "REQUIRED", "SHALL" and "SHALL NOT". Recommendations are expressed using the key words "SHOULD", "SHOULD NOT" and "RECOMMENDED". "MAY" and "OPTIONAL" are used to indicate optional features or behavior. These keywords are used in accordance with [RFC2119]. For legibility these keywords are used in lowercase form.
This section describes the text layout features supported by CSS, which includes support for various international writing directions, such as left-to-right (e.g., Roman scripts), right-to-left (e.g., Hebrew or Arabic), bidirectional (e.g., mixing Roman with Arabic) and vertical (e.g., Asian scripts).
The 'writing-mode' property determines an inline progression and a block (line to line) progression. For example, Roman scripts are typically written left to right and top to bottom. The glyph orientation determines the orientation of the rendered visual shape of characters relative to the inline progression.
Within a line, the adjustment to the current text position is based on the current glyph orientation relative to the inline progression, the metrics of the glyph just rendered, kerning tables in the font and the current values of various attributes and properties, such as the spacing properties.
Bi-directionality introduces another level of complexity in text layout, as in many combinations of 'writing-mode' and glyph orientation values the proper directionality of text will be determined by an algorithm. The Unicode standard ([UNICODE], section 3.12) defines such an algorithm consisting of an implicit part based on character properties, as well as explicit controls for embeddings and overrides. It is also possible to override the inherent directionality of the content characters by using of combination of the 'writing-mode' and 'unicode-bidi' properties.
CSS3 relies on this algorithm to achieve proper text bidirectional rendering. However reordering of characters only occurs for specific values of the glyph orientation properties. See their description for the exact conditions.
CSS2 specified the 'direction' property which is a subset of the 'writing-mode' property as it only determines an inline progression. The 'direction' property may still be used when no block progression change is desired.
The HTML 4.01 specification ([HTML401], section 8.2) defines bi-directionality behavior for HTML elements. Conforming HTML user agents may therefore ignore the 'direction' and 'unicode-bidi' properties in author and user style sheets. The style sheet rules that would achieve the bidi behavior specified in HTML 4.01 are given in the sample style sheet. The HTML 4.01 specification also contains more information on bidirectionality issues. Note that HTML 4.01 does not cover the more general case described by the 'writing-mode' property.
The 'writing-mode' property specifies whether the inline progression shall be left-to-right, right-to-left, or top-to-bottom. (Note that even when the inline progression is left-to-right or right-to-left, some or all of the content within a given element might advance in the opposite direction because of the Unicode [UNICODE] bidirectional algorithm or because of explicit text advance overrides due to this property or 'direction' and 'unicode-bidi'. This property also changes the 'direction' property for the element. For more on bidirectional text, see the section about Embedding and override.
Name: | writing-mode |
Value: | lr-tb | rl-tb | tb-rl | tb-lr | bt-rl | bt-lr | lr | rl | tb |
Initial: | lr-tb |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
The combination of inline progression and block progression set by the writing-mode property is also referred as a flow orientation. In such contexts, the values: lr-tb, lr, rl-tb and rl correspond to horizontal flow orientations, and the others (tb-rl, tb, tb-lr, bt-rl, bt-lr) correspond to vertical flow orientations.
For horizontal flow orientations, the top and bottom margins can be collapsed. For vertical flow orientations, the left and right margin can be collapsed. See Collapsing margins in the CSS3 Box module [forthcoming] for the details of collapsing margins.
This property also specifies the direction of table column layout, the direction of the overflow when determined by the inline progression (such as the 'start' and 'end' value of the 'text-align' property), the initial alignment of text and the position of an incomplete last line in a block in case of 'text-align: justify'.
For the 'writing-mode' property to have any effect on inline-level elements, one or both of the following conditions must be met:
An inline-level element that has a different writing-mode value than its parent becomes an inline-block element.
Here is a diagram of a horizontal flow (writing-mode: lr-tb):
Here is a diagram for a vertical flow used in East Asia (writing-mode: tb-rl) :
And finally, here is a diagram for another flow used for Uyghur and Mongolian (writing-mode: tb-lr):
In East Asian documents, it is often preferred to display certain Latin-based strings, such as numerals in a year, always in a horizontal layout flow regardless of the flow mode of the line of text these strings appear in, as in:
Horizontal in vertical (a.k.a "Tate-chu-yoko")
This effect is known as "Tate chu yoko". In order to achieve it in an XHTML context, the Latin string should be enclosed within a span element with an horizontal flow orientation, as in:
.hinv {writing-mode: lr-tb; display: inline-block;} <span class="hinv">1996</span>
This is an application of changing the flow of an inline element as described earlier. Line breaking is normally disabled for such runs of text. This can be accomplished using the CSS 'white-space: nowrap' property setting.
Name: | direction |
Value: | ltr | rtl |
Initial: | ltr |
Applies to: | all elements and generated content, but see prose |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
Values for this property have the following meanings:
This property specifies the inline progression and the direction of embeddings and overrides (see 'unicode-bidi') for the Unicode bidirectional algorithm. The block progression is not affected by this property. The values 'ltr' and 'rtl' have to be interpreted 'relatively' to the line direction. In addition, it specifies the direction of table column layout, the direction of the overflow when determined by the inline progression (such as the 'start' and 'end' value of the 'text-align' property), the initial alignment of text and the position of an incomplete last line in a block in case of 'text-align: justify'. For the 'direction' property to have any effect on inline-level elements, the 'unicode-bidi' property's value must be 'embed' or 'bidi-override' and the glyph orientation of the characters within the element must be 'auto' or 90/-90 degree in vertical layout or 0/180 degree in horizontal layout.
Note. The 'writing-mode' and 'direction' properties, when specified for table column elements, are not inherited by cells in the column since columns don't exist in the document tree. Thus, CSS cannot easily capture the "dir" attribute inheritance rules described in [[HTML4.01], section 11.3.2.
Note. The 'writing-mode' and 'direction' properties interact with each other. As such, 'writing-mode' resets the 'direction' value. Similarly, modifying 'direction' after 'writing-mode' changes effectively the 'writing-mode' value to the opposite inline progression. For example, 'direction:rtl' applied to an element with 'writing-mode:lr-tb' effectively makes 'writing-mode:rl-tb'. This is one of the main reason why the mixed usage of these two properties is discouraged or at least they should be used with great caution.
In some cases, it is required to alter the orientation of a sequence of characters relative to the inline progression. The requirement is particularly applicable to vertical layouts of East Asian documents, where sometimes half-width Roman text is to be displayed horizontally and other times vertically.
Two properties control the glyph orientation relative to the inline progression. 'glyph-orientation-vertical' controls glyph orientation when the inline progression is vertical. 'glyph-orientation-horizontal' controls glyph orientation when the inline progression is horizontal. It is necessary to distinguish between vertical and horizontal for the following reasons:
Name: | glyph-orientation-vertical |
Value: | <angle> | auto |
Initial: | auto |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: |
specified value (except for initial and inherit) |
Note. A value of auto will generally produce the expected results in common uses of mixing Japanese with European characters; however, the exact algorithms are based on complex interactions between many factors, including font design, and thus different algorithms might be employed in different processing environments. For precise control, specify explicit <angle> values.
This property specifies the orientation of glyphs relative to the inline and block progressions determined by the 'writing-mode' property. This property is applied only to text written in a vertical writing-mode. Conforming user agents may do the following in increasing levels of supports:
The value of this property affects both the alignment and height of the glyph area generated for the affected glyphs. If a glyph is oriented so that the normal orientation of the glyph is parallel to the dominant-baseline, then the vertical alignment-point of the rotated glyph is aligned with the alignment-baseline appropriate to that glyph. The baseline to which the rotated glyph is aligned is the vertical baseline identified by the "alignment-baseline" for the script to which the glyph belongs. The height of the glyph area is determined from the height font characteristic for the glyph.
The horizontal alignment points, baselines and heights (computed as glyph advance width) are used if the normal orientation of the glyph is perpendicular to the dominant-baseline.
The diagrams below illustrate different uses of 'glyph-orientation-vertical'. The diagram on the left shows the result of the mixing of full-width ideographic characters with half-width Roman characters when 'glyph-orientation-vertical' for the Roman characters is either auto or "90deg". The diagram on the right show the result of mixing full-width ideographic characters with half-width Roman characters when Roman characters are specified to have a 'glyph-orientation-vertical' of "0deg".
The bidi algorithm and the 'glyph-orientation-vertical' property have the following interaction:
Name: | glyph-orientation-horizontal |
Value: | <angle> |
Initial: | 0deg |
Applies to: | all inline-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | <angle> |
This property specifies the orientation of glyphs relative to the inline progression determined by the 'writing-mode' property. This property is applied only to text written in a horizontal writing-mode. Conforming user agents may do the following in increasing levels of supports:
The value of this property affects both the alignment and width of the glyph area generated for the affected glyphs. If a glyph is oriented so that the normal orientation of the glyph is parallel to the dominant-baseline, then the vertical alignment-point of the rotated glyph is aligned with the alignment-baseline appropriate to that glyph. The baseline to which the rotated glyph is aligned is the horizontal baseline identified by the "alignment-baseline" for the script to which the glyph belongs. The width of the glyph area is determined from the vertical width font characteristic for the glyph.
The horizontal alignment points, baselines and widths are used if the normal orientation of the glyph is perpendicular to the dominant-baseline.
Name: | unicode-bidi |
Value: | normal | embed | bidi-override |
Initial: | normal |
Applies to: | all elements and generated content, but see prose |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified (except for initial and inherit) |
This property allows further control of the Unicode bidirectional algorithm by allowing new embedding levels or direction overrides. Values for this property have the following meanings:
The final order of characters in each block-level element is the same as if the bidi control codes had been added as described above, mark-up had been stripped, and the resulting character sequence had been passed to an implementation of the Unicode bidirectional algorithm for plain text that produced the same line-breaks as the styled text. In this process, non-textual entities such as images are treated as neutral characters, unless their 'unicode-bidi' property has a value other than 'normal', in which case they are treated as strong characters in the 'direction' specified for the element.
Note. In order to be able to flow inline boxes in a uniform direction (either entirely left-to-right or entirely right-to-left), more inline boxes (including anonymous inline boxes) may have to be created, and some inline boxes may have to be split up and reordered before flowing.
Because the Unicode algorithm has a limit of 61 levels of embedding, care should be taken not to use 'unicode-bidi' with a value other than 'normal' unless appropriate. In particular, a value of 'inherit' should be used with extreme caution. However, for elements that are, in general, intended to be displayed as blocks, a setting of 'unicode-bidi: embed' is preferred to keep the element together in case display is changed to inline (see example below).
The following example shows an XML document with bidirectional text. It illustrates an important design principle: DTD designers should take bidi into account both in the language proper (elements and attributes) and in any accompanying style sheets. The style sheets should be designed so that bidi rules are separate from other style rules. The bidi rules should not be overridden by other style sheets so that the document language's or DTD's bidi behavior is preserved.
Example(s):
In this example, lowercase letters in element contents stand for inherently left-to-right characters and uppercase letters represent inherently right-to-left characters:
<hebrew> <par>HEBREW1 HEBREW2 english3 HEBREW4 HEBREW5</par> <par>HEBREW6 <emph>HEBREW7</emph> HEBREW8</par> </hebrew> <english> <par>english9 english10 english11 HEBREW12 HEBREW13</par> <par>english14 english15 english16</par> <par>english17 <he-quo>HEBREW18 english19 HEBREW20</he-quo></par> </english>
Since this is XML, the style sheet is responsible for setting the writing direction. This is the style sheet:
/* Rules for bidi */ hebrew, he-quo {direction: rtl; unicode-bidi: embed} english {direction: ltr; unicode-bidi: embed} /* Rules for presentation */ hebrew, english, par {display: block} emph {font-weight: bold}
The hebrew element is a block with a right-to-left base direction, the english element is a block with a left-to-right base direction. The par elements are blocks that inherit the base direction from their parents. Thus, the first two par elements are read starting at the top right, the final three are read starting at the top left. Please note that hebrew and english are chosen as element names for explicitness only; in general, element names should convey structure without reference to language.
The emph element is inline-level, and since its value for 'unicode-bidi' is 'normal' (the initial value), it has no effect on the ordering of the text. The he-quo element, on the other hand, creates an embedding.
The formatting of this text might look like this if the line length is long:
5WERBEH 4WERBEH english3 2WERBEH 1WERBEH 8WERBEH 7WERBEH 6WERBEH english9 english10 english11 13WERBEH 12WERBEH english14 english15 english16 english17 20WERBEH english19 18WERBEH
Note that the he-quo embedding causes HEBREW18 to be to the right of english19.
If lines have to be broken, it might be more like this:
2WERBEH 1WERBEH -EH 4WERBEH english3 5WERB -EH 7WERBEH 6WERBEH 8WERB english9 english10 en- glish11 12WERBEH 13WERBEH english14 english15 english16 english17 18WERBEH 20WERBEH english19
Because HEBREW18 must be read before english19, it is on the line above english19. Just breaking the long line from the earlier formatting would not have worked. Note also that the first syllable from english19 might have fit on the previous line, but hyphenation of left-to-right words in a right-to-left context, and vice versa, is usually suppressed to avoid having to display a hyphen in the middle of a line.
In text layout, many of the behaviors are related to a character classification based on scripts. For example, line breaking or text justification behaviors depend on the 'dominant' script of the textual content of an element. Furthermore, baseline alignment may be processed based on the same dominant script. That dominant script can be heuristically determined by finding the first character (after reordering) that has an unambiguous script identifier in an element. It can also be explicitly specified by using the 'text-script' property.
Name: | text-script |
Value: | auto | none | <script> |
Initial: | auto |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | none or <script> (explicit or determined in the case of 'auto') |
Values have the following meanings:
Note 1. The Unicode technical report [UTR-24]: Script Names specifies script allocations for the whole character repertoire covered by the Unicode Standard [UNICODE].
Note 2. Setting an explicit script property value on an element reclassifies all its textual content to the given script. For example setting the script to a script belonging to the CJK group (Chinese, Japanese, Korean) makes the content behave as a CJK content for line-breaking rules. And setting an Arabic text to Latin would prevent the context to be affected by the Kashida justification effect. Typically, this property should be set to an explicit script value only when the textual content is script ambiguous and a specific behavior is sought.
Name: | text-align |
Value: | start | end | left | right | center | justify | <string> |
Initial: | start |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property describes how inline content of a block is aligned. Values have the following meanings:
A block of text is a stack of line boxes. In the case of 'start', 'end', 'left', 'right' and 'center', this property specifies how the inline boxes within each line box align with respect to the line box's start and end sides; alignment is not with respect to the viewport. In the case of 'justify', the UA may stretch the inline boxes in addition to adjusting their positions. (See also 'letter-spacing' and 'word-spacing'.)
Example(s):
In this example, note that since 'text-align' is inherited, all block-level elements inside the div element with 'class=important' will have their inline content centered.
div.important { text-align: center }
Note. The property initial value has changed between CSS2 and CSS3 from being UA dependent in CSS2 to be related to the current text advance direction in CSS3 (through the usage of the 'start' value).
Name: | text-justify |
Value: | auto | inter-word | inter-ideograph | distribute | newspaper | inter-cluster | kashida |
Initial: | auto |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property selects the type of justify alignment. It affects the text layout only if 'text-align' is set to 'justify'. That way, UA's that do not support this property will still render the text as fully justified, which most of the time is at least partially correct. Typically the text-justify property does not affect the last line, unless the last line itself is justified. Most of the text-justify values affects writing systems in very specific ways. These writing systems (or group of) are:
The text-justification behavior of textual components is guided by the script classification of the characters. The 'text-script' property allows to modify the behavior of these components.
Depending on the text-justify value, spacing may be altered between words or letters.
The possible values for the text-justify property are:
The diagram below illustrates this mode, by showing how the characters are laid out in the last two lines of an element:
Mixed glyph layout in the last two lines in an inter-word justified element
For example a viewer could render an 'inter-word' justified paragraph in the following way:
Inter-word justification applied to mixed text
The diagram below illustrates this mode:
Mixed character layout in the last two lines of a newspaper justified element
Note. In CSS3 a value of 'letter-spacing: 0' no longer inhibits spacing-out of words for justification. The letter-spacing value is just an entry to the letter-spacing process that occurs prior to the possible justification process. Justification may alter the initial spacing between letters, especially with the 'text-justify: newspaper' value.
The diagram below illustrates this mode:
Mixed glyph layout in the last two lines in an inter-ideograph justified element
Below is an example of how this mode would work:
Inter-ideograph justification applied to mixed text
The diagram below illustrates this mode:
Mixed character layout in the last two lines of a distribute justified element
For example a viewer could render a 'distribute' justified paragraph in the following way:
Distribute justification applied to mixed text
The following table describes the expansion/compression strategy for the combination of each script groups and the text-justify property value for each relevant text-justify property value:
text-justify property value | |||||||
---|---|---|---|---|---|---|---|
Script groups | auto* | inter-word | newspaper | inter-ideograph | distribute | inter-cluster | kashida |
Latin | word-spacing only* | word-spacing only | prioritization between word-spacing and letter-spacing | word-spacing only | word-spacing and letter-spacing | word-spacing only | word-spacing only |
CJK | no extra spacing* | no extra spacing | letter-spacing | letter-spacing | letter-spacing | no extra spacing | no extra spacing |
Devanagari* | word-spacing* | word-spacing | word-spacing | word-spacing | word-spacing | word-spacing | word-spacing |
Arabic | kashida and word-spacing* | word-spacing | kashida and word-spacing | word-spacing | kashida and word-spacing | word-spacing | kashida and word-spacing |
SE Asian clusters | inter-cluster spacing* | inter-cluster spacing | inter-cluster spacing | no extra spacing | inter-cluster spacing | inter-cluster spacing | no extra spacing |
Interaction between text-justify values and script groups
*The values shown for the auto
column are only a
recommendation. The UAs might implement a different strategy.
*The Devanagari entry represents as well other scripts and writing systems used in India that use baseline connectors like Bengali and Gurmukhi.
Name: | text-align-last |
Value: | auto | start | end | center | justify | size |
Initial: | auto |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property describes how the last line of the inline content of a block
is aligned. This also applies to the only line of a block if it contains a
single line, the line preceding a <br>
element in a XHTML
context, or a hard line break in other languages, and to last lines of
anonymous blocks. Typically the last line is aligned like the other lines of
the block element, this is set by the 'text-align' property. However, in some
situations like when the 'text-align' property is set to 'justify', the
last line may be aligned differently.
Values have the following meanings:
The following XHTML example shows the usage of the alignment properties in a case where all lines are justified in a distributed justification. This is commonly found in East Asian typography:
p.distributealllines { text-align: justify; text-justify: distribute; text-align-last: justify }
Name: | min-font-size |
Value: | <font-size> | auto |
Initial: | auto |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | element's computed 'font-size' |
Media: | visual |
Computed value: | <font-size> |
If 'text-align-last' is 'size', the fonts of the last line of an element are not allowed to become smaller than the smaller of 'font-size' and 'min-font-size'. 'auto' means that the user agent determine the minimum readable font-size for the media. For example, a value is 9px is recommended for Latin scripts.
Name: | max-font-size |
Value: | <font-size> | auto |
Initial: | auto |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | element's computed 'font-size' |
Media: | visual |
Computed value: | <font-size> |
If 'text-align-last' is 'size', the fonts of the last line of an element are not allowed to become larger than the larger of 'font-size' and 'max-font-size'. 'auto' means that there is no limit.
Name: | text-justify-trim |
Value: | none | punctuation | punctuation-and-kana |
Initial: | punctuation |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This sets the individual font blank space compression permissions for the text justification algorithm, when 'text-justify' is anything other than 'inter-word'. This special type of space compression occurs on the font level, i.e. the blank space within the character area itself may be reduced without affecting the appearance of the glyph. This applies to wide-cell glyphs only. Possible values:
Glyph layout with no compression
Glyph layout with punctuation compression
Character layout with punctuation and Kana compression
Name: | text-kashida-space |
Value: | <percentage> |
Initial: | 0% |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | as described |
Media: | visual |
Computed value: | <percentage> |
Kashida is a typographic effect used in Arabic writing systems that allows character elongation at some carefully chosen points in Arabic. Each elongation can be accomplished using a number of kashida glyphs, a single graphic or character elongation on each side of the kashida point. (The UA may use either mechanism based on font or system capability). The text-kashida-space property expresses the ratio of the kashida expansion size to the white space expansion size, 0% means no kashida expansion, 100% means kashida expansion only . This property can be used with any justification style where kashida expansion is used (currently text-justify: auto, kashida, distribute and newspaper).
In the diagram below showing two identical paragraphs of Arabic text, the blue line in the second line (not justified) shows the length that is used for kashida and divided among the elongation opportunities in the first line (justified), as indicated by the red underlines:
Kashida applied to Arabic text
In that example no expansion occurs between the word themselves, indicating that the text-kashida-space property is set to 100%.
Name: | text-indent |
Value: | <length> | <percentage> |
Initial: | 0 |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | refers to width of containing block |
Media: | visual |
Computed value: | <length> |
This property specifies the indentation of the first line of text in a block. More precisely, it specifies the indentation of the first box that flows into the block's first line box. The box is indented with respect to the starting edge of the line box. User agents should render this indentation as blank space. When the 'text-align' property is not set to align the text at the starting edge, this property only specifies a minimum indentation.
Values have the following meanings:
The value of 'text-indent' may be negative, but there may be implementation-specific limits.
Note:
Note: Since the 'text-indent' property inherits, when specified on a block element, it will affect descendent inline-block elements. For this reason, it is often wise to specify 'text-indent: 0' on elements that are specified 'display: inline-block'.
Example(s):
The following example causes a '3em' text indent.
p { text-indent: 3em }
In documents written in Latin-based languages, where runs of characters make up words and words are separated by spaces or hyphens, line breaking is relatively simple. In the most general case, (assuming no hyphenation dictionary is available to the UA), a line break can occur only at whitespace characters or hyphens, including U+00AD SOFT HYPHEN.
In ideographic typography, however, where what appears as a single glyph can represent an entire word and no spaces nor any other word separating characters are needed, a line breaking opportunity is not as obvious as a space. It can occur after or before many other characters. Certain line breaking restrictions still apply, but they are not as strict as they are in Latin typography.
Thai is another interesting example with its own special line breaking rules. Since Thai words are made up of runs of characters, it resembles Latin in that respect. But the lack of spaces as word delimiters, or in fact any consistent word delimiters, makes it similar to CJK. Thai, like Latin in the absence of a hyphenating dictionary, never breaks inside of words. In fact, a knowledge of the vocabulary is necessary to be able to correctly break a line of Thai text. Finally, the Unicode character: U+200B ZERO WIDTH SPACE can be inserted in such scripts to specify an explicit line breaking opportunity.
A number of levels of line-breaking "strictness" can be used in Japanese typography. These levels add or remove line breaking restrictions. The model presented in this specification distinguishes between two most commonly used line breaking levels for Japanese text, using the 'line-break' property.
In ideographic typography, it is also possible, though not always preferred, to allow line breaks to occur inside of quoted Latin and Hangul (Korean) words without following the line breaking rules of those particular scripts. The model proposed in this document gives the author control over that behavior through the 'word-break-CJK' property.
In addition, hyphenation is controlled by 'word-break-inside'. All these properties are also available through the 'word-break' short hand property.
Finally, there is an additional property 'wrap-option' which may influence line-breaking, especially the property value 'wrap-option: emergency' which provides for emergency word-breaking for long words.
Line breaking is also covered by the Unicode Standard Annex [UAX-14], available from the Unicode Web site. It contains a detailed recommendation and corresponding data for each Unicode character.
Name: | line-break |
Value: | normal | strict |
Initial: | normal |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property selects the set of line breaking rules to be used for text. The values described below are especially useful to CJK authors, but the property itself is open to other, not yet specified settings for non-CJK authors as well. (This is an area for future expansion.)
In Japanese, a set of line breaking restrictions is referred to as "Kinsoku". JIS X-4051 [JIS-X-4051] is a popular source of reference for this behavior using the strict set of rules. This architecture involves character classification into line breaking behavior classes. Those classes are then analyzed in a two dimensional behavior table where each row-column position represents a pair action to be taken at the occurrence of these classes. For example, given a closing character class and an opening character class, the intersection in that table of these two classes (the first character belonging to the opening class and the second belonging to the closing class) will indicate no line breaking opportunity. The rules described by JIS X-4051 have been superseded by the Unicode Technical Report #14 mentioned earlier.
Note that both values, 'normal' and 'strict' imply that a set of line-breaking restrictions is in use. In fact, there appears to be no valid line breaking mode in CJK in which line breaks can appear just anywhere among ideographs.
Name: | word-break-CJK |
Value: | normal | break-all | keep-all |
Initial: | normal |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property controls line-breaking behavior inside of words from a CJK point of view. Possible values:
The following example shows a paragraph style where all non-CJK scripts can break anywhere.
p.anywordbreaks { word-break: break-all }
Name: | word-break-inside |
Value: | normal | hyphenate |
Initial: | normal |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property controls the hyphenation behavior inside of words. Possible values:
Name: | word-break |
Value: | <'word-break-CJK'> || <'word-break-inside'> |
Initial: | see individual properties |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | see individual properties |
The 'word-break' property is a shorthand property for setting 'word-break-CJK', and 'word-break-inside', at the same place in the style sheet.
All word-break related properties are first reset to their initial values (all 'normal'). Then, those properties that are given explicit values in the 'word-break' shorthand are set to those values.
The following section describes text wrapping, white-space handling and text overflow. Text wrapping and white-space handling are interrelated through the CSS2 'white-space' property combining these two effects together. Text wrapping and text overflow both deal with situation where the text reaches the flow after-edge of its containing box.
CSS3 clearly separates these three effects in different sets of property while keeping the 'white-space' property for compatibility reason.
Name: | wrap-option |
Value: | wrap | hard-wrap | soft-wrap | emergency |
Initial: | wrap |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property controls whether or not text wraps when it reaches the flow edge of its containing block box. Several value descriptions use the term preserved line feed characters (U+000A). A preserved line-feed character (either from the source content or from occurrence of "\A" in generated content) is maintained for presentation purpose and may therefore influence text wrapping. The preserved status of line-feed characters is determined by the 'linefeed-treatment' property. The 'wrap-option' possible values are:
White-space processing in the context of CSS is the mechanism by which all white-space characters are interpreted for rendering purpose. The white-space set is determined by the XML [XML1.0] specification as being a combination of one or more space characters (Unicode value U+0020), carriage returns (U+000D), line feeds (U+000A), or tabs (U+0009).
Note: [HTML401] also defines the form feed character (U+000C) as a white space character, but that character is not part of any XHTML versions as they are all based on XML.
The amount of white space processing that can be achieved by a user agent that supports CSS is directly related to the CSS processing model, especially the document parsing and validation. After parsing and possible validation, the document tree may contain text nodes that contain unprocessed white space characters, or the document tree may already have been processed in a way that white space characters have been collapsed and partially removed (white space normalization).
In that respect, the CSS properties related to white space processing can only be effective if the CSS processor has access to the white space characters that were originally encoded in the document. However, end-of-line characters are typically handled (like by XML processors) in such a way that any arbitrary combination of end-of-line characters is replaced by a single line feed character (U+000A).
Note: XML Schema, through its 'whiteSpace' facet can constrain exactly the type of white space characters still available to a rendering process like CSS for elements containing string datatype. In addition, some XML languages like [XHTML1.0] may have their own white-space processing rules when parsing and validating documents with white-space characters. Therefore, some of the behaviors described below may be affected by these limitations and may be user agent dependent in these contexts.
In addition, line feed characters can be inserted in generated content by using the '\A' string. The behavior of these inserted line feed characters is identical to original line feed characters part of the source document and is controlled by the same set of properties.
The initial white-space processing, similar to [XHTMLMOD] is as follows:
Note: These rendering rules make no assumption about
the storage model of these white-space character sequences. It is outside the
scope of CSS to determine the character code values accessible through
programming interface such as DOM. These rules do not apply to elements that
have an explicit white-space rendering behavior (like the pre
element in XHTML).
Note: In determining how to convert a LINE FEED character a user agent should consider the following cases, whereby the script of characters on either side of the LINE FEED determines the choice of the replacement. Characters of COMMON script (such as punctuation) are treated as the same as the script on the other side:
If the characters preceding and following the LINE FEED character belong to a script in which the SPACE character is used as a word separator, the LINE FEED character should be converted into a SPACE character. Examples of such scripts are Latin, Greek, and Cyrillic.
If the characters preceding and following the LINE FEED character belong to an ideographic-based script or writing system in which there is no word separator, the LINE FEED should be converted into no character. Examples of such scripts or writing systems are Chinese, Japanese.
If the characters preceding and following the LINE FEED character belong to a non ideographic-based script in which there is no word separator, the LINE FEED should be converted into a ZERO WIDTH SPACE character (​) or no character. Examples of such scripts are Thai, Khmer.
If none of the conditions in (1) through (3) are true, the LINE FEED character should be converted into a SPACE character.
The Unicode [UNICODE] technical report TR#24 (Script Names) [UTR-24] provides an assignment of script names to all characters.
When white-space characters are collapsed for rendering purpose, the style applied to the collapsed set is the one that would be applied to first white-space character of the set.
The following properties: 'linefeed-treatment', 'white-space-treatment' and 'all-space-treatment' allow precise control of that behavior. The 'linefeed-treatment' determines the rendering of the line feed characters. The 'white-space-treatment' determines the rendering of white space character (except line feed). And the 'all-space-treatment' property determines the treatment of consecutive white-space characters after consideration of the two prior properties. The 'white-space' property is a shorthand property for these three properties as well as the 'wrap-option' property.
Name: | linefeed-treatment |
Value: | auto | ignore | preserve | treat-as-space | treat-as-zero-width-space | ignore-if-after-linefeed |
Initial: | auto |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property specifies the treatment of linefeeds (U+000A characters). Values have the following meanings:
Note: The Unicode Standard [UNICODE] recommends that the zero width space is considered a valid line-break point and that if two characters with a zero width space in between are placed on the same line they are placed with no space between them; and that if they are placed on two lines no additional glyph area, such as for a hyphen, is created at the line-break.
Name: | white-space-treatment |
Value: | ignore | preserve | ignore-if-before-linefeed | ignore-if-after-linefeed
| ignore-if-surrounding-linefeed |
Initial: | ignore-if-surrounding-linefeed |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property specifies the treatment of space (U+0020) and other white-space characters except for linefeeds (U+000A), since their treatment is determine by the linefeed-treatment property. White-space characters, when rendered as an advance width, use the width of the space character (U+0020). Values have the following meanings:
Name: | all-space-treatment |
Value: | preserve | collapse |
Initial: | collapse |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
The "all-space-treatment" property specifies the treatment of all consecutive white-space characters (with no exception for linefeed characters, unlike the "white-space-treatment" property). Values have the following meanings:
Name: | white-space |
Value: | normal | pre | nowrap | pre-wrap | pre-lines |
Initial: | not defined for shorthand properties |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | see individual properties |
This property declares how 'white-space' inside the element is handled. Setting a value on the 'white-space' property set the respective values on 'wrap-option', 'linefeed-treatment', 'white-space-treatment' and 'all-space-treatment'. Although, strictly speaking, the property has no initial value, it is equivalent to 'normal'. The definition of the property values are established by referring to the individual white-space properties set as follows:
white-space: | wrap-option: | linefeed-treatment: | white-space-treatment: | all-space-treatment: |
---|---|---|---|---|
normal | wrap | auto | ignore-if-surrounding-linefeed | collapse |
pre | hard-wrap | preserve | preserve | preserve |
nowrap | hard-wrap | auto | ignore-if-surrounding-linefeed | collapse |
pre-wrap | wrap | preserve | preserve | preserve |
pre-lines | wrap | preserve | ignore-if-surrounding-linefeed | collapse |
Example(s):
The following examples show what white-space behavior is expected from the PRE and P elements, and the "nowrap" attribute in HTML, and in generated content.
pre { white-space: pre } p { white-space: normal } td[nowrap] { white-space: nowrap } :before, :after {white-space: pre-lines }
In addition, the effect of an HTML PRE element with the non-standard "wrap" attribute is demonstrated by the following example:
pre[wrap] {white-space: pre-wrap }
Text overflow deals with the situation where some textual content is clipped when it overflows the element's box in its text advance direction as determined by the writing-mode property value. This situation may only occur when the 'overflow' property has the values: hidden, scroll and auto (in the latter case only when the UA behavior results in content scrolling).
Text overflow allows the author to introduce a visual hint at the two ending boundaries of the text flow within the element box (after and end). The hint is typically an ellipsis character "...", although the actual character representation may vary. An image may also be substituted. Setting a non empty string (or an uri for an image) for either text flow boundary enables the presentation of the hint. If both hints should appear, only the 'after' hint is rendered. Initially, only the end of line hint is shown (correspond to the right of any over flown lines for left to right inline progression).
The text-overflow is divided in properties: 'text-overflow-mode' that controls the presentation of hint characters, 'text-overflow-ellipsis' that controls the values of the hint characters presented at the box boundaries and a shorthand property: 'text-overflow'.
Name: | text-overflow-mode |
Value: | clip | ellipsis | ellipsis-word |
Initial: | clip |
Applies to: | all block-level elements |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
The hint characters only replace textual information. If the clipping occurs on a replaced element, standard clipping occurs.
Although the property is not inherited, overflowing children blocks that are either statically or relatively positioned and do not have a specified width or height will be hinted as specified by their parent text-overflow-mode property value. Consider the following example:
<div class="citation"> <p class="sentence"><span class="nowrap">I didn't like the play,</span> but then I saw it under adverse conditions - the curtain was up. <div class="attributed-to">_Groucho_Marx_</div> </p> </div>
Here is the style sheet controlling the overflow situations:
div.citation { width:100px; border: thin solid red; overflow: hidden; text-overflow-mode:ellipsis;font-size:14px } span.nowrap { white-space : nowrap; } div.attributed-to { position: relative;left:8px }
This will result in the content of the span to be partially visible and the ellipsis will be shown, the inner div which is relatively positioned will only show a partial ellipsis as it is offset by few pixels:
Other children blocks, like absolute positioned blocks, or blocks with specified width or height won't show hinting. For example, setting the p element of the previous figure with the following style:
p.sentence { width :100px; margin-top : 50px; margin-left : 50px; }
will result on no ellipsis shown for its content (because it has a specified width and furthermore the text wrapping occurs in the 'hidden' overflow area of its parent element). This would be shown like this:
In other words, the text-overflow-mode only affects the textual content of a block element which participate in its own inline flow.
Name: | text-overflow-ellipsis |
Value: | [<ellipsis-end> | <uri> [, <ellipsis-after> | <uri>]?] |
Initial: | "..." |
Applies to: | all block-level elements |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
The font-size used for the ellipsis characters is the element font-size.
Name: | text-overflow |
Value: | <'text-overflow-mode'> || <'text-overflow-ellipsis'> |
Initial: | not defined for shorthand properties |
Applies to: | all block-level elements |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | see individual properties |
This property is the shorthand for 'text-overflow-mode' and 'text-overflow-ellipsis'.
Name: | letter-spacing |
Value: | normal | <length> |
Initial: | normal |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | <length> or 'normal' |
This property specifies spacing behavior between text characters. Values have the following meanings:
Because of the visual disruptive effect of modifying letter-spacing on writing systems which use joined characters, like for example Arabic, the usage of this property is discouraged in those cases.
There are cases like Japanese or Chinese writing systems where justification will change all letter-spacing effects as there is no other opportunity in the line to expand or compress the character content in order to fit the line span.
Character spacing algorithms are user agent-dependent. For example, the spacing will not occur necessarily between all characters, but instead between each glyph that constitutes either a letter or a cluster unit. Furthermore this property should not be used for scripts and/or fonts that link characters together (cursive fonts for Roman scripts, all Arabic cases, Indic scripts with headline like Devanagari, etc...). Character spacing may also be influenced by justification (see the 'text-align' property).
Example(s):
In this example, the space between characters in blockquote elements is increased by '0.1em'.
blockquote { letter-spacing: 0.1em }
In the following example, the user agent is requested not to alter inter-character space:
blockquote { letter-spacing: 0cm } /* Same as '0' */
When the resultant space between two characters is not the same as the default space, user agents should not use ligatures.
Name: | word-spacing |
Value: | normal | none | <length> |
Initial: | normal |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | <length>, 'normal' or 'none' |
This property specifies spacing behavior between words. Values have the following meanings:
Word spacing algorithms are user agent-dependent. Determining word boundary is typically done by detecting white space characters. There are however many scripts and writing systems that do not separate their words by any character (like Japanese, Chinese, Thai, etc...), detecting word boundaries in these cases require dictionary based algorithms that may not be supported by all user agents. Word spacing is also influenced by justification (see the 'text-align' property).
Example(s):
In this example, the word-spacing between each word in H1 elements is increased by '1em'.
h1 { word-spacing: 1em }
Name: | punctuation-trim |
Value: | none | start |
Initial: | none |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property determines whether or not a full-width punctuation mark character should be trimmed if it appears at the beginning of a line, so that its "ink" lines up with the first glyph in the line above and below. In some scenarios, it may be preferable for the author not to allow leading punctuation marks to be trimmed, for example when it is more important that the glyphs tend to line up vertically. In other scenarios such an effect is desirable, for example when it is more important for the author that as much text as possible fits on a single line.
Possible values:
Glyph layout with no leading punctuation compression
Glyph layout with leading punctuation compression
(Note that this property may in the future be expanded to cover other punctuation behaviors for other types of punctuation as well, not just wide-cell.)
Name: | text-autospace |
Value: | none | [ideograph-numeric || ideograph-alpha || ideograph-space || ideograph-parenthesis] |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
When a run of non-ideographic or numeric characters appears inside of ideographic text, a certain amount of space is often preferred on both sides of the non-ideographic text to separate it from the surrounding ideographic glyphs. This property controls the creation of that space when rendering the text. That added width does not correspond to the insertion of additional space characters, but instead to the width increment of existing glyphs.
(A commonly used algorithm for determining this behavior is specified in JIS X-4051 [JIS-X-4051].)
This property is additive with the 'word-spacing' and 'letter-spacing' [CSS2] properties, that is, the amount of spacing contributed by the 'letter-spacing' setting (if any) is added to the spacing created by 'text-autospace'. The same applies to 'word-spacing'.
Possible values:
span.autospace { text-autospace:none; }
<span class="autospace">[ideographs]1997[ideographs]</span>
would appear as:
Mixed glyph layout when autospace is disabled
while changing the style to the following:
span.autospace { text-autospace:ideograph-numeric; }
would make the same text appear more like:
Mixed glyph layout when autospace is enabled
Name: | kerning-mode |
Value: | none | [pair || contextual] |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property controls all kerning effects. Some kerning effects are based on information located explicitly on fonts (pair-kerning). Others are based on context and typical ink placement within characters and don't rely on font information. Pair kerning is used mainly for Latin, Greek and Cyrillic scripts, while contextual kerning is more common in East Asian context. A typical example of pair kerning is the pair 'Wa'. A good example of contextual kerning is the pair '[[' (when using the wide width variant). Possible values:
Name: | kerning-pair-threshold |
Value: | auto | <length> |
Initial: | auto |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | <length> or 'auto' |
This property controls the font size threshold, above which pair kerning would be active (if enabled). Possible values:
Until CSS2, the only text decorations available were available through the 'text-decoration' property exposing itself various effects underline, overline, line-through, etc... and the text-shadows property. However the text-decoration property has some limitations stemming from its syntax, which allows for multiple 'text-decoration' formatting effects to be specified at the same time but it precludes finer control over each of those formatting effects. More specifically, it offers no way to control the color or line style of the underline, overline or line-through.
CSS3 extends the model by introducing new properties allowing additional controls over those formatting effects. CSS3 also makes turning these formatting effects on or off possible without affecting any other 'text-decoration' settings.
Furthermore, to reflect the usage of underline in East Asian vertical writing, a new control is offered on the underline positioning, this allows the underline to appear before (on the right in vertical text flow) or after (on the left in vertical text flow) the formatted text. The property is called 'text-underline-position'.
The 'text-decoration' property itself is now a shorthand property for all these new properties, but it only takes its own set of values which affects all the other text decoration properties.
These properties describe decorations that are added to the text of an element. If they are specified for a block-level element, it affects the root inline box (the anonymous inline box which wraps all the inline children of an element).
If they are specified for (or affects) an inline-level element, it affects all boxes generated by the element. If an element is empty or is a replaced element (e.g., the IMG element in XHTML), user agents must ignore these properties. Text content also excludes white space characters that are collapsed during the white space processing.
All these text decoration properties are not inherited, but descendant boxes should be formatted with the same decoration (e.g., they should all be underlined). The color of decorations should remain the same even if descendant elements have different 'color' values.
Finally, user agents may chose either to average thickness and positions of the 'line' text-decorations based on the children text size and baselines, or to ignore the text of children. The following figure shows the averaging for underline:
On these 3 segments of underline text, the underline bar is drawn lower and thicker as the ratio of large text increase for the each consecutive underlined text segment.
Note: Typically the underline superscript text segments are averaged, while the subscript segments are not.
Names: | text-underline-style, text-line-through-style, text-overline-style |
Value: | none | solid | double | dotted | thick | dashed | dot-dash | dot-dot-dash | wave |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
These properties specifies the line style for underline, line-through and overline text decoration. Possible values:
The following figure shows the appearance of these various line styles.
The line styles
Names: | text-underline-color, text-line-through-color, text-overline-color |
Value: | auto | <color> |
Initial: | auto |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
These property specifies the line color for the underline, line-through and overline text decorations. Possible values:
Name: | text-underline-mode, text-line-through-modetext-overline-mode |
Value: | continuous | words |
Initial: | continuous |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
These properties set the mode for the underline, line-through and overline text decorations, determining whether the text decoration affects the white-space characters or not. Possible values:
Name: | text-underline-position |
Value: | auto-pos | before-edge | after-baseline | after-edge |
Initial: | auto-pos |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property sets the position of the underline when set through the 'text-underline-style' property. It can appear either 'before' (above in an horizontal flow) or after (below in an horizontal flow) the run of text in relation to its baseline orientation. This property is typically used in vertical writing context where it may be desired to have the underline appear 'before' the run of text. This results in having the underline appearing on the right side of the vertical writing column. Possible values:
Name: | text-blink |
Value: | none | blink |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property specifies the blink mode. Possible values:
The 'text-underline' property is the shorthand for 'text-underline-style', 'text-underline-color', 'text-underline-mode' and 'text-underline-position'.
Name: | text-underline |
Value: | <'text-underline-style'> || <'text-underline-color'> || <'text-underline-mode'> || <'text-underline-position'> |
Initial: | not defined for shorthand properties |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
The 'line-through' property is the shorthand for 'text-line-through-style', 'text-line-through-color' and 'text-line-through-mode'.
Name: | text-line-through |
Value: | <'text-line-through-style'> || <'text-line-through-color'> || <'text-line-through-mode'> |
Initial: | not defined for shorthand properties |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | see individual properties |
This 'text-overline' property is the shorthand for 'text-overline-style', 'text-overline-color' and 'text-overline-mode'.
Name: | text-overline |
Value: | <'text-overline-style'> || <'text-overline-color'> || <'text-overline-mode'> |
Initial: | not defined for shorthand properties |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | see individual properties |
The 'text-decoration' property is a shorthand that takes its own set of values.
Name: | text-decoration |
Value: | none | [ underline || overline || line-through || blink] |
Initial: | see individual properties |
Applies to: | all elements and generated content |
Inherited: | no (see prose) |
Percentages: | N/A |
Media: | visual |
Computed value: | see individual properties |
The 'text-decoration' shorthand sets the properties 'text-underline-style', 'text-underline-color', 'text-underline-mode', 'text-underline-position', 'text-line-through-style', 'text-line-through-color', 'text-line-through-mode', 'text-overline-style', 'text-overline-color', 'text-overline-mode' and 'text-blink' to their default values, and then the values of the shorthand change these defaults as follows:
Conforming user agents are not required to support the 'blink' value.
Although the property has no explicit initial value, it is equivalent to the value 'none.
Example(s):
In the following example for XHTML, the text content of all a elements acting as hyperlinks will be underlined and blinking:
a[href] { text-decoration: underline blink }
Name: | text-shadow |
Value: | none | [<color> || <length> <length> <length>? ,]* [<color> || <length> <length> <length>?] |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified values (except for initial and inherit) |
This property accepts a comma-separated list of shadow effects to be applied to the text of the element. The shadow effects are applied in the order specified and may thus overlay each other, but they will never overlay the text itself. Shadow effects do not alter the size of a box, but may extend beyond its boundaries. The stack level of the shadow effects is the same as for the element itself.
Each shadow effect must specify a shadow offset and may optionally specify a blur radius and a shadow color.
A shadow offset is specified with two <length> values that indicate the distance from the text. The first length value specifies the horizontal distance to the right of the text. A negative horizontal length value places the shadow to the left of the text. The second length value specifies the vertical distance below the text. A negative vertical length value places the shadow above the text.
A blur radius may optionally be specified after the shadow offset. The blur radius is a length value that indicates the boundaries of the blur effect. The exact algorithm for computing the blur effect is not specified. User agents may only implement only part of this property by ignoring blur effects. Such user agents should consider declarations that specify the optional third parameter to be parser errors, as described in the Syntax module [link TBD].
A color value may optionally be specified before or after the length values of the shadow effect. The color value will be used as the basis for the shadow effect. If no color is specified, the value of the 'color' property will be used instead.
Text shadows may be used with the ::first-letter and ::first-line pseudo-elements.
Example(s):
The example below will set a text shadow to the right and below the element's text. Since no color has been specified, the shadow will have the same color as the element itself, and since no blur radius is specified, the text shadow will not be blurred:
h1 { text-shadow: 0.2em 0.2em }
The next example will place a shadow to the right and below the element's text. The shadow will have a 5px blur radius and will be red.
h2 { text-shadow: 3px 3px 5px red }
The next example specifies a list of shadow effects. The first shadow will be to the right and below the element's text and will be red with no blurring. The second shadow will overlay the first shadow effect, and it will be yellow, blurred, and placed to the left and below the text. The third shadow effect will be placed to the right and above the text. Since no shadow color is specified for the third shadow effect, the value of the element's 'color' property will be used:
h2 { text-shadow: 3px 3px red, yellow -3px 3px 2px, 3px -3px }
Example(s):
Consider this example:
span.glow { background: white; color: white; text-shadow: black 0px 0px 5px; }
Here, the 'background' and 'color' properties have the same value and the 'text-shadow' property is used to create a "solar eclipse" effect:
Note. This property is not defined in CSS1. Some shadow effects (such as the one in the last example) may render text invisible in UAs that only support CSS1.
It is very common for the glyphs in documents written in East Asian languages, such as Chinese or Japanese, to be laid out on the page according to a specified one- or two-dimensional grid. The concept of grid can also be used in other, non-ideographic contexts such as Braille or monospaced layout.
The diagram below represents a fragment of horizontal text on a page with mixed wide-cell and narrow-cell glyphs that a Japanese user intended to be laid out on a grid which resulted in 9 glyphs per line (gray grid lines shown for clarity):
'Genko' grid applied to mixed text
The grid behavior can be set on the line progression, on the block progression or both. The grid on the block progression is determined by the following properties:
The block progression grid is not described in this section as it can be simply achieved by using the appropriate line related properties mentioned above and described in the CSS3 Line module.
The grid on the line progression is obtained by altering the character advance width (or line progression) of inline elements. There are several modes:
Two properties control this advance width modification: 'line-grid-mode' enables it and 'line-grid-progression' determines its value. The shorthand 'line-grid' allows to set both together.
Name: | line-grid-mode |
Value: | none | ideograph | all |
Initial: | none |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
Specifies the line grid behavior. Each line grid mode value entails a different set of rules for rendering inline contents. Possible values:
No line grid. Standard text alignments apply to the block element.
Mixed glyph layout in strict grid
Object layout in strict grid
The ideograph mode disables all special text justification and glyph width adjustment normally applied to the contents of the block element.
If a line break opportunity cannot be found in a text run going over the line boundary, then that text run will be pushed down to the next line and the last part of the previous line will be left blank.
Here is an example of mixed text in ideograph grid mode:
Strict grid applied to mixed text
Mixed glyph layout in fixed grid
For example:
Fixed grid applied to mixed text
The 'letter-spacing' property does not apply to characters in a grid but does apply for all characters not in the grid (i.e. all characters for 'line-grid-mode: none', non-ideographs for 'line-grid-mode: ideograph' and all non-connected glyphs for 'line-grid-mode: all').
Name: | line-grid-progression |
Value: | text-height | line-height | <length> |
Initial: | normal |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | <length> |
This property affects the line progression of characters subject to the fixed advance width as determined by the 'line-grid-mode' property.
Possible values:
div.section1 { line-grid-progression: .5in }
would make each glyph in a horizontally laid out part of a document rendered within 0.5 inch of horizontal space:
Enlarged character grid applied to mixed text in horizontal layout
If the section's layout flow is vertical, then 0.5in becomes the vertical distance between consecutive characters in a column:
Enlarged character grid applied to mixed text in vertical-ideographic layout
Name: | line-grid |
Value: | <'line-grid-mode'> || <'line-grid-progression'> |
Initial: | not defined for shorthand properties |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | see individual properties |
The 'line-grid' property is a shorthand property for setting 'line-grid-mode', 'line-grid-progression'. The following is an example of setting the grid in both progression:
div.grid { line-height:20pt; text-height: max-size; line-stacking-strategy: grid-height; line-grid: ideograph line-height; }
This set for the div element a grid with 20pt inline and block progression dimensions. All ideographs will be set in cells sized in multiple of 20pt in both direction.
Name: | text-transform |
Value: | capitalize | uppercase | lowercase | none |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property controls capitalization effects of an element's text. Values have the following meanings:
Although limited, the case mapping process has some language dependencies. Some well known examples are Turkish and Greek. See HTML [HTML40] for ways to find the language of an HTML element. XML, and consequently [XHTML1.0], uses an attribute called xml:lang and there may be other language-specific language-specific methods to determine the language.
The case mapping rules for the character repertoire specified by the Unicode Standard 3.0 can be found on the Unicode Consortium web site: http://www.unicode.org.
Conforming user agents must support case mapping rules according to the Unicode Standard 3.0 for all characters specified by that standard. Note that the conformance rule is more stringent than the ones specified in lower levels of CSS.
Example:
In this example, all text in an h1 element is transformed to uppercase text.
h1 { text-transform: uppercase }
Name: | hanging-punctuation |
Value: | none | start | end | both |
Initial: | none |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property determines whether a punctuation mark, if one is present, may be placed outside the content area in the padding or margin area, at the start or at the end of a full line of text. Allowing a punctuation to 'hang' at the end of a line is is a common practice in East Asian typography. It is the responsibility of the style writer to create meaningful padding and margin areas to allow effective rendering of the punctuation. It should also be noted that compression may occur in the line, including compression of the punctuation characters independently of this effect.
Possible values:
Here is an example where overhanging is not allowed:
No hanging punctuation allowed (the punctuation and the character preceding it shown in blue for clarity)
In the following example overhanging is allowed at the end of the content area.
Hanging punctuation appearing in the end of line padding area (the punctuation and the character preceding it shown in blue for clarity)
Note: User agents should follow the convention of the scripts for trimming either only the first lines or all lines. For example, in Roman text, only a punctuation appearing at the starting point of the first line may be placed outside the content area. It would look improper in other lines. The following figure shows an example of correct usage.
Name: | text-combine |
Value: | none | letters | lines |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property controls the creation of composite characters (a.k.a. "kumimoji") or lines (a.k.a. "warichu").
Possible values:
No more than 5 glyphs can be combined at a time. If more than five are included inside of the element with this property setting, only the first five are combined. The rest is rendered as regular text. If the text to be combined results in a single glyph, no special combination effect occurs. The following texts shows the arrangement for 2, 3, 4 and 5 characters:
The valid "Kumimoji" arrangements
The following mark-up:
span.kumimoji { text-combine: letters }
could make the following 4 characters appear as one (shown in blue for clarity):
"Kumimoji" applied to four characters
The following figure shows a typical usage for this feature.
Glyph layout in "Warichu"
The following mark-up:
span.warichu { text-combine: lines }
would make the enclosed text look like the following (shown in blue for clarity):
"Warichu" applied to 10 characters
In addition to the specified values, all properties take the
Property | Values | Initial | Applies to | Inh. | Percentages | Media |
---|---|---|---|---|---|---|
all-space-treatment | preserve | collapse | collapse | all elements and generated content | yes | N/A | visual |
direction | ltr | rtl | ltr | all elements and generated content, but see prose | yes | N/A | visual |
glyph-orientation-horizontal | <angle> | 0deg | all inline-level elements | yes | N/A | visual |
glyph-orientation-vertical | <angle> | auto | auto | all elements and generated content | yes | N/A | visual |
hanging-punctuation | none | start | end | both | none | block-level elements | yes | N/A | visual |
kerning-mode | none | [pair || contextual] | none | all elements and generated content | yes | N/A | visual |
kerning-pair-threshold | auto | <length> | auto | all elements and generated content | yes | N/A | visual |
line-grid | <'line-grid-mode'> || <'line-grid-progression'> | not defined for shorthand properties | block-level elements | yes | N/A | visual |
line-grid-mode | none | ideograph | all | none | block-level elements | yes | N/A | visual |
line-grid-progression | text-height | line-height | <length> | normal | block-level elements | yes | N/A | visual |
letter-spacing | normal | <length> | normal | all elements and generated content | yes | N/A | visual |
line-break | normal | strict | normal | all elements and generated content | yes | N/A | visual |
linefeed-treatment | auto | ignore | preserve | treat-as-space | treat-as-zero-width-space | ignore-if-after-linefeed | treat-as-space | all elements and generated content | yes | N/A | visual |
max-font-size | <font-size> | auto | auto | all elements and generated content | yes | element's computed 'font-size' | visual |
min-font-size | <font-size> | auto | auto | all elements and generated content | yes | element's computed 'font-size' | visual |
punctuation-trim | none | start | none | block-level elements | yes | N/A | visual |
text-script | auto | none | <script> | auto | all elements and generated content | yes | N/A | visual |
text-align | start | end | left | right | center | justify | <string> | start | block-level elements | yes | N/A | visual |
text-align-last | auto | start | end | center | justify | size | auto | block-level elements | yes | N/A | visual |
text-autospace | none | [ideograph-numeric || ideograph-alpha || ideograph-space || ideograph-parenthesis] | none | all elements and generated content | yes | N/A | visual |
text-blink | none | blink | none | all elements and generated content | no | N/A | visual |
text-combine | none | letters | lines | none | all elements and generated content | no | N/A | visual |
text-decoration | none | [ underline || overline || line-through || blink] | not defined for shorthand properties | all elements and generated content | no (see prose) | N/A | visual |
text-indent | <length> | <percentage> | 0 | block-level elements | yes | refers to width of containing block | visual |
text-justify | auto | inter-word | inter-ideograph | distribute | newspaper | inter-cluster | kashida | auto | block-level elements | yes | N/A | visual |
text-justify-trim | none | punctuation | punctuation-and-kana | punctuation | block-level elements | yes | N/A | visual |
text-kashida-space | <percentage> | 0% | block-level elements | yes | as described | visual |
text-line-through | <'text-line-through-style'> || <'text-line-through-color'> || <'text-line-through-mode'> | not defined for shorthand properties | all elements and generated content | no | N/A | visual |
text-line-through-color | auto | <color> | auto | all elements and generated content | no | N/A | visual |
text-line-through-mode | continuous | words | continuous | all elements and generated content | no | N/A | visual |
text-line-through-style | none | solid | double | dotted | thick | dashed | dot-dash | dot-dot-dash | wave | none | all elements and generated content | no | N/A | visual |
text-overflow | <'text-overflow-mode'> || <'text-overflow-ellipsis'> | not defined for shorthand properties | all block-level elements | no | N/A | visual |
text-overflow-ellipsis | [<ellipsis-end> | <uri> [, <ellipsis-after> | <uri>]?] | "..." | all block-level elements | no | N/A | visual |
text-overflow-mode | clip | ellipsis | ellipsis-word | clip | all block-level elements | no | N/A | visual |
text-overline | <'text-overline-style'> || <'text-overline-color'> || <'text-overline-mode'> | not defined for shorthand properties | all elements and generated content | no | N/A | visual |
text-overline-color | auto | <color> | auto | all elements and generated content | no | N/A | visual |
text-overline-mode | continuous | words | continuous | all elements and generated content | no | N/A | visual |
text-overline-style | none | solid | double | dotted | thick | dashed | dot-dash | dot-dot-dash | wave | none | all elements and generated content | no | N/A | visual |
text-shadow | none | [<color> || <length> <length> <length>? ,]* [<color> || <length> <length> <length>?] | none | all elements and generated content | no (see prose) | N/A | visual |
text-transform | capitalize | uppercase | lowercase | none | none | all elements and generated content | yes | N/A | visual |
text-underline | <'text-underline-style'> || <'text-underline-color'> || <'text-underline-mode'> || <'text-underline-position'> | not defined for shorthand properties | all elements and generated content | no | N/A | visual |
text-underline-color | auto | <color> | auto | all elements and generated content | no | N/A | visual |
text-underline-mode | continuous | words | continuous | all elements and generated content | no | N/A | visual |
text-underline-position | auto-pos | before-edge | after-baseline | after-edge | auto-pos | all elements and generated content | no | N/A | visual |
text-underline-style | none | solid | double | dotted | thick | dashed | dot-dash | dot-dot-dash | wave | none | all elements and generated content | no | N/A | visual |
unicode-bidi | normal | embed | bidi-override | normal | all elements and generated content, but see prose | no | N/A | visual |
white-space | normal | pre | nowrap | pre-wrap | pre-lines | not defined for shorthand properties | all elements and generated content | yes | N/A | visual |
white-space-treatment | ignore | preserve | ignore-if-before-linefeed | ignore-if-after-linefeed | ignore-if-surrounding-linefeed | ignore-if-surrounding-linefeed | all elements and generated content | yes | N/A | visual |
word-break | <'word-break-CJK'> || <'word-break-inside'> | see individual properties | all elements and generated content | yes | N/A | visual |
word-break-CJK | normal | break-all | keep-all | normal | all elements and generated content | yes | N/A | visual |
word-break-inside | normal | hyphenate | normal | all elements and generated content | yes | N/A | visual |
word-spacing | normal | none | <length> | normal | all elements and generated content | yes | N/A | visual |
wrap-option | wrap | hard-wrap | soft-wrap | emergency | wrap | all elements and generated content | yes | N/A | visual |
writing-mode | lr-tb | rl-tb | tb-rl | tb-lr | bt-rl | bt-lr | lr | rl | tb | lr-tb | all elements and generated content | yes | N/A | visual |
The following properties are defined in other specifications:
There are 3 modules defined by this chapter:
CSS1 text model:
CSS2 text model:
CSS3 text model:
The CSS1 text module is made of the following properties/values:
Name | Values | Initial | Applies to | Inherited | Percentages | Media groups |
---|---|---|---|---|---|---|
'letter-spacing' | normal | <length> | normal | all elements | yes | N/A | N/A |
'text-align' | left | right | center | justify | start | block-level elements | yes | N/A | N/A |
'text-decoration' | none | [ underline || overline || line-through || blink ] | none | all elements | no (see prose) | N/A | N/A |
'text-indent' | <length> | <percentage> | inherit | 0 | block-level elements | yes | refers to width of containing block | N/A |
'text-transform' | capitalize | uppercase | lowercase | none | inherit | none | all elements | yes | N/A | N/A |
'word-spacing' | normal | <length> | normal | all elements | yes | N/A | N/A |
'white-space' | normal | pre | nowrap | normal | all elements | yes | N/A | N/A |
Concerning the 'text-align' property, a conforming CSS1 user agent my interpret the value 'justify' as 'left' or 'right', depending on whether the element's current text direction is left-to-right or riht-to-left respectively.
The following table describes the CSS2 text module. Because all properties have added the 'inherit' value and have a media type, all CSS1 properties have been specified below as well. The properties added are: 'direction', 'text-shadow' and 'unicode-bidi'. In addition, the 'text-align' has a new value: <string>. Concerning the 'text-align' property, a conforming CSS1 user agent my interpret the value 'justify' as 'left' or 'right', depending on whether the element's current text direction is left-to-right or riht-to-left respectively. Properties that applies to all elements also applies to generated content.
.Name | Values | Initial | Applies to | Inherited | Percentages | Media groups |
---|---|---|---|---|---|---|
'direction' | ltr | rtl | inherit | ltr | all elements and generated content, but see prose | yes | N/A | visual |
'letter-spacing' | normal | <length> | inherit | normal | all elements and generated content | yes | N/A | visual |
'text-align' | left | right | center | justify | <string> | inherit | start | block-level elements | yes | N/A | visual |
'text-decoration' | none | [ underline || overline || line-through || blink] | inherit | none | all elements and generated content | no (see prose) | N/A | visual |
'text-indent' | <length> | <percentage> | inherit | 0 | block-level elements | yes | refers to width of containing block | visual |
'text-shadow' | none | [<color> || <length> <length> <length>? ,]* [<color> || <length> <length> <length>?] | inherit | none | all elements and generated content | no (see prose) | N/A | visual |
'text-transform' | capitalize | uppercase | lowercase | none | inherit | none | all elements and generated content | yes | N/A | visual |
'unicode-bidi' | normal | embed | bidi-override | inherit | normal | all elements and generated content, but see prose | no | N/A | visual |
'white-space' | normal | pre | nowrap | inherit | normal | block-level elements | yes | N/A | visual |
'word-spacing' | normal | <length> | inherit | normal | all elements and generated content | N/A | visual |
The CSS3 module adds the following properties:
It also modifies the following properties as described:
In general, the existing [CSS2] properties that imply directionality or position are absolute, i.e. "left" means "left" and "top" means "top" regardless of the writing mode of the page. The purpose of this appendix however is to list the exceptions to that rule and clarify ambiguities. If a property does not appear in this list, it is intended to be interpreted as absolute, i.e. it does not rotate when the layout mode changes.
CSS Property | Effect in vertical layout |
---|---|
'clear' | 'float' and 'clear' property values interpretation is absolute in horizontal flow and logical in vertical flow (left is start, right is end) |
'direction' | relative (logical), i.e. ltr implies top-to-bottom character progression in vertical layout |
'display' | relative (logical), i.e. the values that are directional (table-) are relative to the element orientation as specified by the writing mode. |
'float' | [see the note about 'clear'] |
'line-height' | relative (logical), i.e. this controls the "height" of a line if horizontal, or the "width", if vertical. In other words, this controls the size of the line in the dimension perpendicular to the baseline. |
'quotes' | relative (logical), the concept of open-quotes and close-quotes is already used in CSS. Note that the quote glyph may vary depending on the glyph-orientation. |
'text-align' | 'left' and 'right' are physical in horizontal inline progression and UA dependent in vertical inline progression. 'start' and 'end' are always relative. |
'text-decoration' | relative (logical), i.e. underline and overline are parallel to the baseline. Underline appears on the left side of a vertical column and overline appears on the right |
'unicode-bidi' | relative (logical), i.e. it affects glyph progression regardless of layout |
'vertical-align' | relative (logical), top and bottom values maps to before and after-edge values in baseline alignment properties |
This specification would not have been possible without the help from:
Ayman Aldahleh, Stephen Deach, Martin Dürst, Laurie Anna Edlund, Ben Errez, Yaniv Feinberg, Arye Gittelman, Richard Ishida, Koji Ishii, Masayasu Ishikawa, Michael Jochimsen, Eric LeVine, Chris Pratley, Rahul Sonnad, Frank Tang, Chris Thrasher, Masafumi Yabe.