Copyright © 2005 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This CSS3 module defines properties for text manipulation and specifies their processing model. It covers line breaking, justification and alignment, white space handling, text decoration and text transformation.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This Text Effects module and a separate (upcoming) Text Layout module replace and obsolete the May 2003 CSS3 Text Module Candidate Recommendation. Since this is a thorough overhaul of the previous version, a list of changes has been provided instead of a diff.
This document is a Working Draft, and it is still very incomplete. In fact, the majority of its sections have not been added in. Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than a work in progress. Feedback on this draft should be posted to the www-style@w3.org mailing list with [CSS3 Text] in the subject line. You are strongly encouraged to complain if you see something stupid in this draft. I will do my best to respond to all feedback.
If you have implemented properties from CSS3 Text CR please let me know so I can take that into account as I redraft the spec. You can post to www-style (public), post to the CSS WG mailing list (Member-restricted), or email fantasai directly (personal).
This document has been produced as a combined effort of the W3C Internationalization Activity, and the Style Activity and is maintained by the CSS Working Group. It also includes contributions made by participants in the XSL Working Group (members only). Patent disclosures relevant to CSS may be found on the Working Group's public patent disclosure page..
The following features are at risk and may be cut from the spec during
its CR period: multiple text shadows, the tibetan
text
justification mode, the 'text-outline' property, the 'skip-spaces'
text-line-mode
[document here]
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 (see [RFC2119]). However, for readability, these words do not typically appear in all uppercase letters in this specification.
Additional key words, e.g. "User agent (UA)", are defined by CSS 2.1 ([CSS21], section 3.1).
UAs must treat as invalid any properties or values they do not support. Experimental implementations of a feature should support only a vendor-prefixed syntax for the property/value.
White space processing in CSS interprets white space characters for rendering: it has no effect on the underlying document data. In the context of CSS, the document white space set is defined to be any space characters (Unicode value U+0020), tab characters (U+0009), or line break characters (defined by the document format: typically line feed, U+000A). Control characters besides the white space characters and the bidi formatting characters (U+202x) are treated as normal characters and rendered according to the same rules.
The document parser must normalize line break character sequences according to its own format rules before CSS processing takes effect. However, in generated content strings the line feed character (U+000A) and only the line feed character is considered a line break sequence. For CSS white space processing all line breaks must be normalized to a single character representation—usually the line feed character (U+000A)—here called a "line break". This way, all recognized line breaks are treated the same and style rules behave consistently across systems.
The document parser may have not only normalized line break characters, but also collapsed other space characters or otherwise processed 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.
Name: | white-space-collapse |
---|---|
Value: | preserve | collapse | preserve-breaks | discard |
Initial: | collapse |
Applies to: | all elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
This property declares whether and how white space inside the element is collapsed. Values have the following meanings, which must be interpreted according to the white space processing rules:
collapse
preserve
preserve-breaks
discard
Any text that is directly contained inside a block (not inside an inline) is treated as being inside an anonymous inline element.
For each inline (including anonymous inlines), white space characters are handled as follows, ignoring bidi formatting characters as if they were not there:
If 'white-space-collapse' is set to 'collapse' or 'preserve-breaks', white space characters are considered collapsible and are processed by performing the following steps:
If 'white-space-collapse' is set to 'preserve', any sequence of spaces (U+0020) unbroken by an element boundary is treated as a sequence of non-breaking spaces. However, a line breaking opportunity exists at the end of the sequence.
If 'white-space-collapse' is set to 'discard', the first white space character in every white space sequence is converted to a zero width non-joiner (U+200C) and the rest of the sequence is removed.
Then, the entire block is rendered. Inlines are laid out, taking bidi reordering into account, and wrapping as specified by the 'text-wrap' property.
As each line is laid out,
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-collapse' property is set
to 'collapse', the above processing model would result in the
following:
This would leave two spaces, one after the A in the left-to-right embedding level, and one after the B in the right-to-left embedding level. This is then ordered according to the Unicode bidirectional algorithm, with the end result being:
A BC
Note that there are two spaces between A and B, and none between B and C. This is best avoided by putting spaces outside the element instead of just inside the opening and closing tags and, where practical, by relying on implicit bidirectionality instead of explicit embedding levels.
When line breaks are collapsible, they are either transformed into a space (U+0020) or removed depending on the script context before and after the line break.
The script context is determined by the Unicode-given script value [UAX24] of the first character that side of the line break. However, characters such as punctuation that belong to the COMMON and INHERITED scripts are ignored in this check; the next character is examined instead. The UA must not examine characters outside the block and may limit its examination to as few as four characters on each side of the line break. If the check fails to find an acceptable script value (i.e. it has hit the check limits), then the script context is neutral.
Comments on how well this would work in practice would be very much appreciated, particularly from people who work with Thai and similar scripts.
Name: | white-space |
---|---|
Value: | normal | pre | nowrap | pre-wrap | pre-line |
Initial: | not defined for shorthand properties |
Applies to: | all elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | see individual properties |
The 'white-space' property is a shorthand for the 'white-space-collapse' and 'text-wrap' properties. Not all combinations are represented. Values have the following meanings:
normal
pre
nowrap
pre-wrap
pre-line
The following informative table summarizes the behavior of various 'white-space' values:
New Lines | Spaces and Tabs | Text Wrapping | |
---|---|---|---|
normal | Collapse | Collapse | Wrap |
pre | Preserve | Preserve | No wrap |
nowrap | Collapse | Collapse | No wrap |
pre-wrap | Preserve | Preserve | Wrap |
pre-line | Preserve | Collapse | Wrap |
In many writing systems, words are always separated by spaces or punctuation. In the absence of a hyphenation dictionary, a line break can occur only at these explicit word boundaries. In Chinese and Japanese typography, however, no spaces nor any other word separating characters are used. In these systems a line can break anywhere except between certain character combinations. Additionally the level of strictness in these restrictions can vary with the typesetting style.
Scripts like Thai, which uses a space to separate clauses rather than to separate words, present another type of line breaking case. The lack of visible word delimiters makes it similar to the CJK systems. However, like English in the absence of a hyphenating dictionary, Thai never breaks inside words. As a result, knowledge of the vocabulary is necessary to be able to correctly break a line of Thai text. To explicitly mark word boundaries, the zero width space (U+200B) can be used as a word delimiter in Thai and similar scripts.
CSS distinguishes between two levels of strictness in the rules for implicit line breaking in CJK text. The precise set of rules in effect for the strict and loose levels is up to the UA and should follow language conventions. However, this specification does recommend that the following breaks be forbidden in strict line breaking and allowed in loose:
Information on line breaking conventions can be found in [JIS4051] for Japanese, [标点符号] for Chinese, and [?] for Korean, and in [UAX14].
Name: | word-break |
---|---|
Value: | normal | keep-all | loose | break-strict | break-all |
Initial: | normal |
Applies to: | all elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
This property specifies what set of line breaking restrictions are in effect within the element. Values have the following meanings:
normal
keep-all
loose
break-strict
break-all
When shaping scripts such as Arabic are allowed to break within words due to 'break-all' or 'break-strict', the characters must still be shaped as if the word were not broken.
Name: | hyphenate |
---|---|
Value: | none | auto |
Initial: | none |
Applies to: | all elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
This property determines whether the line-breaking algorithm is allowed to use a hyphenation engine to break within words. Intra-word breaking restrictions have no effect when 'word-break' is 'break-all'. Possible values:
none
auto
If hyphenation is applied to a shaped script such as Arabic then the shaping must be done ignoring the hyphenation.
Text wrapping is controlled by the 'text-wrap' and 'word-wrap' properties:
Name: | text-wrap |
---|---|
Value: | normal | unrestricted | none | suppress |
Initial: | normal |
Applies to: | all elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
This property specifies the mode for text wrapping. Possible values:
normal
none
unrestricted
suppress
When 'text-wrap' is set to 'normal' or 'suppress', UAs that allow breaks at punctutation other than spaces should prioritize breakpoints. For example, if breaks after slashes have a lower priority than spaces, the sequence "check /etc" will never break between the '/' and the 'e'. The UA may use the width of the containing block, the text's language, and other factors in assigning priorities.
The priority of breakpoints can be set to reflect the intended grouping of text.
Given the rules
footer { text-wrap: suppress; /* inherits to all descendants */ }
and the following markup:
<footer> <venue>27th Internationalization and Unicode Conference</venue> • <date>April 7, 2005</date> • <place>Berlin, Germany</place> </footer>
In a narrow window the footer could be broken as
27th Internationalization and Unicode Conference • April 7, 2005 • Berlin, Germany
or in a narrower window as
27th Internationalization and Unicode Conference • April 7, 2005 • Berlin, Germany
but not as
27th Internationalization and Unicode Conference • April 7, 2005 • Berlin, Germany
Name: | word-wrap |
---|---|
Value: | normal | break-word |
Initial: | normal |
Applies to: | all elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
This property specifies whether the UA may break within a word to prevent overflow when an otherwise-unbreakable string is too long to fit within the containing block. It only has an effect when 'text-wrap' is either 'normal' or 'suppress'. Possible values:
normal
break-word
Name: | text-align |
---|---|
Value: | start | end | left | right | center | justify | <string> |
Initial: | start |
Applies to: | all elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
This property describes how inline contents of a block are horizontally aligned. Values have the following meanings:
start
end
left
right
center
justify
<string>
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 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 the 'text-justify', 'text-justify-trim', 'text-kashida-space', 'letter-spacing' and 'word-spacing'.)
Name: | text-align-last |
---|---|
Value: | start | end | left | right | center | justify |
Initial: | start |
Applies to: | all elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
This property describes how the last line of a block or a line right before a forced line break is aligned when 'text-align' is set to 'justify'. Values have the same meaning as for 'text-align'.
Name: | text-justify |
---|---|
Value: | auto | inter-word | inter-ideograph | inter-character | inter-cluster | kashida | tibetan |
Initial: | auto |
Applies to: | all elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
This property selects the justification method used when 'text-align' is set to 'justify'. It takes the following values:
auto
inter-word
inter-ideograph
inter-character
inter-cluster
kashida
tibetan
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. If the 'letter-spacing' and 'word-spacing' property values allow it, the user agent may also distribute negative space, putting more content on the line than would otherwise fit under normal spacing conditions. The exact justification algorithm is UA-dependent; however, CSS defines some general guidelines which must be followed when any justification method other than 'auto' is specified.
Justification affects different types of writing systems in different ways. For justification purposes, writing systems are grouped as follows:
Where do scripts like Tamil fit in?
The UA may enable or break optional ligatures or use other font features such as alternate glyphs to help justify the text under any method. This behavior is not defined by CSS.
CSS defines flex points as points where the justification algorithm may alter spacing within the text. Flex points occur at word separators and between grapheme clusters. These flex points fall into priority levels as defined by the justification method. Within a line, higher priority flex points must be expanded or compressed to their limits before later priority flex points may be adjusted. These limits are given by the the letter-spacing and word spacing properties. How any remaining space is distributed once all flex points reach their limits is up to the UA. 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 (or as 'start' if 'text-align-last' is 'justify').
The flex point priorities for values of 'text-justify' are given in the table below. Space must be distributed evenly among all types of flex points in a given prioritization group, but may vary within a line due to changes in the font or letter-spacing and word-spacing values. The different types of flex points are defined as follows:
I'm not sure grapheme clusters are the right unit to use for some of these complex scripts...
method: | inter-word | inter-ideograph | inter-character | inter-cluster | kashida | tibetan | auto | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
priority: | 1st | 2nd | 1st | 2nd | 1st | 2nd | 1st | 2nd | 1st | 2nd | 3rd | 1st | 2nd | 3rd | - |
special | • | • | ? | ||||||||||||
spaces | • | • | • | • | • | • | |||||||||
discrete | • | • | • | • | • | • | |||||||||
block | • | • | • | • | • | • | |||||||||
clustered | • | • | • | • | • | • | |||||||||
connected | • | • | • | • | • | • | |||||||||
cursive | • | • | • | • | • | ||||||||||
tibetan | • | • | • | • | • | • |
The two values kashida
and tibetan
trigger
special justification behavior as specified below. This special behavior
takes priority over the flex point adjustment described above.
The next two properties refer to the <spacing-limit> value type, which is defined as follows:
<spacing-limit>
If only two values are specified, the third is assumed to be the same as the second. If only one value is specified, all three values are the same. The first spacing value specifies the desired (optimum) spacing. The second value specifies the desired minimum spacing limit, and the third specifies the desired maximum spacing limit.
If the minimum spacing value is greater than the optimum spacing value, then the used minimum spacing value is the optimum spacing value. If the maximum spacing value is less than the optimum spacing value, then the used maximum spacing value is the optimum spacing value.This substitution occurs after inheritance.
normal
<length> or
<percentage>
Name: | word-spacing |
---|---|
Value: | <spacing-limit> |
Initial: | normal |
Applies to: | all elements |
Inherited: | yes |
Percentages: | refers to width of space (U+0020) glyph |
Media: | visual |
Computed value: | 'normal' or computed value or percentage |
This property specifies the minimum, maximum, and optimal spacing between words. In the absence of justification the optimal spacing must be used. The text justification process may alter the spacing from its optimum (see the 'text-justify' property, above) but must not violate the minimum spacing limit and should also avoid exceeding the maximum.
Spacing is applied to each word-separator character left in the text after the white space processing rules have been applied and should be applied half on each side of the character. This is correct for Ethiopian and doesn't matter for invisible spaces, but is it correct for Tibetan? Most publications seem to add space after the tsek mark during justification. Word-separator characters include the space (U+0020), the no-break space (U+00A0), the Ethiopic word space (U+1361), the ideographic space (U+3000), the Aegean word separators (U+10100,U+10101), the Ugaritic word divider (U+1039F), and the Tibetan tsek (U+0F0B, U+0F0C). Is this list correct? If there are no word-separator characters, or if the 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 are not considered word-separators.
Name: | letter-spacing |
---|---|
Value: | <spacing-limit> |
Initial: | normal |
Applies to: | all elements |
Inherited: | yes |
Percentages: | refers to width of space (U+0020) glyph |
Media: | visual |
Computed value: | 'normal' or computed value or percentage |
This property specifies the minimum, maximum, and optimal spacing between grapheme clusters. In the absence of justification the optimal spacing must be used. The text justification process may alter the spacing from its optimum (see the 'text-justify' property, above) but must not violate the minimum spacing limit and should also avoid exceeding the maximum. Letter-spacing is applied in addition to any word-spacing.
A grapheme cluster is what a language user considers to be a character or a basic unit of the script. The term is described in detail in the Unicode Technical Report: Text Boundaries [UAX29]. This specification relies on the default (not tailored) rules only.
Spacing must not be applied at the beginning or at the end of a line. At element boundaries, the letter spacing is given by and rendered within the innermost element that contains the boundary. For example, given the markup
<P>a<LS>b<Z>cd</Z><Y>ef</Y></LS>g</P>
and the style sheet
LS { letter-spacing: 1em; } Z { letter-spacing: 0.3em; } Y { letter-spacing: 0.4em; }
the spacing would be
a[0]b[1em]c[0.3em]d[1em]e[0.4em]f[0]g
UAs may apply letter-spacing to cursive scripts. In this case, UAs must extend the space between disjoint graphemes as specified above and extend the visible connection between cursively connected graphemes by the same amount (rather than leaving a gap). If the UA cannot expand a cursive script this way, it must not apply letter-spacing between grapheme clusters of that script at all.
UAs must not apply letter-spacing to connected scripts. Or should they?
When the resulting space between two characters is not the same as the default space, user agents should not use optional ligatures.
Put something here. What sort of settings are needed?
Put text from CSS2.1 here once http://lists.w3.org/Archives/Public/www-style/2003Nov/0021.html has been addressed.
Name: | text-decoration |
---|---|
Value: | none | [ underline || overline || line-through || blink ] |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | no (see prose) |
Percentages: | N/A |
Media: | visual |
Computed value: | as specified |
This property specifies what decorations are added to the text of an element.
none
underline
overline
line-through
blink
Name: | text-line-color |
---|---|
Value: | <color> |
Initial: | currentColor |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | a color |
This property specifies the line color for underline, line-through and overline text decorations applied to the element. The color of the decoration must remain the same across descendants even if descendant elements have different 'color' or 'text-line-color' values.
Name: | text-line-style |
---|---|
Value: | [ solid | double | dotted | dashed | dot-dash | dot-dot-dash | wave ] || thick |
Initial: | solid |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | as specified |
This property specifies the line style for underline, line-through and overline text decorations applied to the element. The style of the decoration must remain the same across descendants even if descendant elements have different 'text-line-style' values. Values have the following meanings:
solid
double
dotted
dashed
dot-dash
dot-dot-dash
wave
The thick
keyword specifies an underline thickness that is thicker (typically
one-third to twice as thick) than the normal style. If it appears
without a style keyword, 'solid' is assumed.
The following figure demonstrates the appearance of these various line styles.
Name: | text-line-mode |
---|---|
Value: | continuous | [ skip-spaces || skip-images ] |
Initial: | continuous |
Applies to: | all elements and generated content |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | as specified |
This property determines whether text decoration is drawn through white space and replaced content. Values have the following meanings:
continuous
skip-spaces
skip-images
Name: | text-emphasis |
---|---|
Value: | none | [ [ accent | dot | circle | disc] [ before | after ]? ] |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | as specified |
East Asian documents use small symbols on top of each glyph to emphasize a run of text. For example:
Accent emphasis (shown in blue for clarity) applied to Japanese text
This property applies emphasis formatting applied to text. Unlike 'text-decoration', emphasis marks can affect the line height. Values have the following meanings:
none
accent
dot
circle
disc
before
after
The list of shapes here is copied from the CSS3 Fonts module drafts, and it is not correct or at least not complete. Any input on what shapes are needed, what usage patterns are found in real texts, etc. would be much appreciated. Send them off to www-style@w3.org or www-international@w3.org with [CSS3 Text] in the subject line.
The preferred position of emphasis marks depends on the language. In Japanese for example, the preferred position is 'before'. In Chinese used in the PRC, on the other hand, the preferred position is 'after'. The informative table below summarizes the preferred emphasis mark position for Chinese and Japanese:
Language | Preferred mark position | Illustration |
---|---|---|
Japanese | before |
![]() |
Chinese (Traditional) | before | |
Chinese (Simplified) | after |
![]() |
Name: | text-shadow |
---|---|
Value: | none | [<shadow>, ] * <shadow> |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | a color plus three absolute <length>s |
This property accepts a comma-separated list of shadow effects to
be applied to the text of the element. <shadow>
is defined as
[
<color>?
<length>
<length>
<length>?
|
<length>
<length>
<length>?
<color>?
]
,
where the first two lengths represent the offset and the third an
optional blur radius. The shadow is applied to all of the element's
text as well as any text decoration applied to it.
Would it be better to apply shadows together with
text decoration: i.e. a descendent of an underlined element doesn't
apply shadow to its underline, but the underlining element, if it has
shadows, would apply it to the underline of all text it underlines.
When a text outline is specified, the shadow
shadows the outlined shape rather than the glyph shape.
The shadow offset is specified with two <length> values that indicate an offset from direct alignment with 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. If the blur radius is not specified, it is equal to zero.
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 color of the shadow effect. If the color is not specified, a UA-chosen color will be used.
The shadow effects are applied in the order specified should this be changed to layer the same way multiple backgrounds do (earlier on top)? 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. Does this definition cause problems with the shadow of one element painting over the text of the previous element? How would we solve that?
Text shadows may be used with the :first-letter and :first-line pseudo-elements.
Name: | text-outline |
---|---|
Value: | none | [ <color> <length> <length>? | <length> <length>? <color> ] |
Initial: | none |
Applies to: | all elements and generated content |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | a color plus two absolute <length>s |
This property specifies a text outline where the first length represents
the outline's thickness and the second represents an optional blur radius.
The outline never overlays the text itself. Its effect is the same as that
obtained by applying text shadows in every radial direction, i.e. all text
shadows whose offsets satisfy the equation
x2 + y2 = thickness2
.
The Timed-Text WG had suggestions for some keywords (text-outline: normal|heavy|light;) as well as a <length> thickness. Should these be added? How would they be defined? (Maybe use (thin|medium|thick) as in border-width?)
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, but it is only applied to the outer edge of the outline. If the blur radius is not specified, it is equal to zero. Is a second blur radius needed for the inner edge? Or should the blur apply to both edges? Implementations may choose to ignore the blur radius when text outline is combined with a text shadow.
A color value must be specified before or after the length values of the outline effect. The color value will be used as the color of the outline.
Text outlines may be used with the :first-letter and :first-line pseudo-elements.
Name: | text-indent |
---|---|
Value: | [ <length> | <percentage> ] hanging? |
Initial: | 0 |
Applies to: | block-level, inline-block elements and table cells |
Inherited: | yes |
Percentages: | refers to width of containing block |
Media: | visual |
Computed value: | the percentage as specified or the absolute length |
This property specifies the indentation applied to lines of inline content in a block. The indendation only affects the first line of inline content in the block unless the 'hanging' keyword is specified, in which case it affects all lines except the first.
The indent is treated as a margin applied to the start edge of the line box. The amount of indentation is given by the length or percentage value. Percentages are relative to the containing block, even in the presence of floats. They are inherited as percentages, not as absolute lengths.
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:
Since CSS1 it has been possible <-- -->to indent the first line of a block <-- -->element using the 'text-indent' <-- -->property.
The original proposal for this syntax included a dependence on alignment, written as follows and with the following extra example:
The indent is treated as a margin applied to the alignment edge of the line box. The alignment edge depends on the value of 'text-align'. It is:
- the start edge of the line box if 'text-align' is a string value, 'start', or 'justify'.
- the end edge of the line box if 'text-align' is 'end'.
- the left edge of the line box if 'text-align' is 'left'.
- the right edge of the line box if 'text-align' is 'right'.
If 'text-align' is 'center', then the indentation is split evenly between both ends of the line box.
Example. The following rule would cause text to be centered in its block, with the first line allowed to fill the block's width but subsequent lines restricted to only half of it:
p { text-align: center: text-indent: 50% hanging; border: dashed; }
Since CSS1 it has been possible to indent the first line of a block element using the 'text-indent' property.
None of the web browsers tested at the time (WinIE6, Nav7 and Opera7) displayed this behavior, so Michel decided to keep the indentation on the start edge always. However, perhaps it would be useful to adopt the centered indentation for text-align: center; a start-edge indentation is pretty useless on centered text (it just looks weird), and I don't imagine many authors would be relying on that behavior.
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'.
Name: | hanging-punctuation |
---|---|
Value: | none | [ start || end || end-edge ] |
Initial: | none |
Applies to: | block-level, inline-block elements and table cells |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | as specified |
This property determines whether a punctuation mark, if one is present, may be placed outside the line box at the start or at the end of a full line of text. If a justified line can fit the punctuation will it expand to push it outside the content area? No. What if the line ends in multiple punctuation marks? Which punctuation marks are affected? Values have the following meanings:
start
end
end-edge
Need to work on the description. Cover indentation as well.
To be continued...
Much of the text has been rewritten or severely revised, so all changes will not be listed here. Highlights include:
Many sections intended for this module are not yet represented in this draft. In particular, the 'text-justify-trim', 'text-overflow', 'text-decoration', 'text-transformation', 'punctuation-trim', 'text-autospace', 'text-shadow', 'hanging-punctuation', 'kerning-mode', and related properties have not yet been evaulated.
Sections relating to text layout (vertical text, grids, 'text-combine') will be moved to a separate Text Layout module. These features may change greatly from the last revision, but they have not been dropped. The vertical text feature, for example, will likely be based on the methods described in Unicode Technical Note #22.
This specification would not have been possible without the help from: Ayman Aldahleh, Bert Bos, Tantek Çelik, Stephen Deach, Martin Dürst, Laurie Anna Edlund, Ben Errez, Yaniv Feinberg, Arye Gittelman, Ian Hickson, Martin Heijdra, Richard Ishida, Koji Ishii, Masayasu Ishikawa, Michael Jochimsen, Eric LeVine, Chris Lilley, Paul Nelson, Chris Pratley, Martin Sawicki, Rahul Sonnad, Frank Tang, Chris Thrasher, Etan Wexler, Chris Wilson, Masafumi Yabe and Steve Zilles.