CSS text-overflow Property
Example
.example1 {
white-space: nowrap;
width: 200px;
overflow: hidden;
text-overflow: clip;
border: 1px solid black;
}
.example2 {
white-space: nowrap;
width: 200px;
overflow: hidden;
text-overflow: ellipsis;
border: 1px solid black;
}
.example3 {
white-space: nowrap;
width: 200px;
overflow: hidden;
text-overflow: "----";
border: 1px solid black;
}
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Meaning
The text-overflow property sets how hidden overflow content is signaled to users.
It can be clipped, display an ellipsis ('…'), or display a custom string.
The text-overflow property doesn't force an overflow to occur. To make text overflow its container, you have to set other CSS properties: overflow and white-space.
overflow: hidden;
white-space: nowrap;
Default value: | clip |
Inherited: | No |
Animatable: | No |
Version: | CSS3 |
JavaScript syntax: |
|
Standard Syntax
text-overflow: clip|ellipsis|initial|inherit|revert|revert-layer|unset;
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Status
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
clip | This is default value. The text is clipped and not accessible. |
ellipsis | Sets an ellipsis ("...") to represent the clipped text. |
string | Sets the given string to represent the clipped text. |
fade | This keyword clips the overflowing inline content and applies a fade-out effect near the edge of the line box with complete transparency at the edge. |
fade( length | percentage ) | This function clips the overflowing inline content and applies a fade-out effect near the edge of the line box with complete transparency at the edge.
The argument determines the distance over which the fade effect is applied. The percentage is resolved against the width of the line box. Values lower than 0 are clipped to 0. Values greater than the width of the line box are clipped to the width of the line box. |
initial | Sets this property to its default value. |
inherit | If specified, the associated element takes the computed value of its parent element animation-delay property. |
revert | Reverts the cascaded value of the property from its current value to the value the property |
revert-layer | Rollback styles to the ones specified in previous cascade layers. |
unset | Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not. |
Default CSS Property Values
selectors {
text-overflow: clip;
}