CSS3 text-overflow
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The text-overflow
CSS property determines how the text content will be displayed, when it overflows the block container element that has overflow
other than visible
.
The following table summarizes the usages context and the version history of this property.
Default value: | clip |
---|---|
Applies to: | Block containers |
Inherited: | No |
Animatable: | No. See animatable properties. |
Version: | New in CSS3 |
Note: Text can overflow, when it is prevented from wrapping e.g. due to white space set to nowrap for the containing element or a single word is too long to fit.
Syntax
The syntax of the property is given with:
The example below shows the text-overflow
property in action.
Example
Try this code »p {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
clip |
Clip text as appropriate for the text content. Characters may be only partially rendered. |
ellipsis |
Render an ellipsis character ('...', U+2026) to represent clipped text. |
string | Render the given string to represent clipped text. The string is displayed inside the content area, shortening more the size of the displayed text. If there are not enough places to display string, they are clipped. |
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element text-overflow property. |
Browser Compatibility
The text-overflow
property is supported in all major modern browsers.
Basic Support—
|
Note: Internet Explorer supports the prefixed version -ms-text-overflow
that can be used as a synonym for text-overflow
. Opera 9 and 10 supports the prefixed version, -o-text-overflow
.
Further Reading
See tutorial on: CSS Overflow, CSS Text.
Text-related properties: letter-spacing
, text-align
, text-decoration
, text-indent
, text-shadow
, text-transform
, white-space
, word-spacing
.