--- title: text-overflow slug: Web/CSS/text-overflow translation_of: Web/CSS/text-overflow ---
La propiedad de CSS text-overflow determina como el contenido que se desborda y que no es mostrado, va a hacérsele notar a los usuarios. Puede ser cortado, mostrar una elipsis ('…', U+2026 Horizontal Ellipsis), o mostrar una cadena de texto personalizada.
La propiedad text-overflow no fuerza a que ocurra un desbordamiento. Para hacer que un texto desborde a su contenedor debes poner algunas otras propiedades de CSS. Por ejemplo:
overflow: hidden; white-space: nowrap;
La propiedad text-overflow solo afecta al contenido que está rebasando un elemento de contenedor en bloque en su dirección de progresión inline (no así, a un texto que rebase por el bottom del contenedor, por).
La propiedad text-overflow ha de ser especificada usando uno o dos valores. Si se define solo un valor, este determinará el comportamiento del overflow para el final de la línea (el extremo derecho en un texto izquierda-a-derecha o el extremo izquierdo en un texto derecha-a-izquierda). Si se definen dos valores, el primero hará referencia al comportamiento overflow para para el extremo izquierdo y el segundo al extremo derecho de la línea.
Cada valor se especificará como una de las siguientes opciones:
clip, ellipsis, fadefade(), que recibe {{cssxref("<length>")}} o {{cssxref("<percentage>")}} para controlar la distancia de desvanecimiento<string>.cliptext-overflow as an empty string, if that is supported in your target browsers: text-overflow: '';.ellipsis'…', U+2026 Horizontal Ellipsis) to represent clipped text. The ellipsis is displayed inside the content area, decreasing the amount of text displayed. If there is not enough space to display the ellipsis, it is clipped.<string> {{experimental_inline}}fade {{experimental_inline}}fade( <length> | <percentage> ) {{experimental_inline}}0 are clipped to 0. Values greater than the width of the line box are clipped to the width of the line box.p {
width: 200px;
border: 1px solid;
padding: 2px 5px;
/* BOTH of the following are required for text-overflow */
white-space: nowrap;
overflow: hidden;
}
.overflow-visible {
white-space: initial;
}
.overflow-clip {
text-overflow: clip;
}
.overflow-ellipsis {
text-overflow: ellipsis;
}
.overflow-string {
/* Not supported in most browsers,
see the 'Browser compatibility' section below */
text-overflow: " [..]";
}
<p class="overflow-visible">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p> <p class="overflow-clip">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p> <p class="overflow-ellipsis">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p> <p class="overflow-string">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
{{EmbedLiveSample('Examples', 300, 220, '', 'Web/CSS/text-overflow')}}
| CSS value | direction: ltr |
direction: rtl |
||
|---|---|---|---|---|
| Expected Result | Live result | Expected Result | Live result | |
| visible overflow | 1234567890 |
1234567890
|
0987654321 |
1234567890
|
text-overflow: clip |
![]() |
![]() |
||
text-overflow: '' |
12345 |
123456
|
54321 |
1234567890
|
text-overflow: ellipsis |
1234… | …4321 | ||
text-overflow: '.' |
1234. |
1234567890
|
.4321 |
1234567890
|
text-overflow: clip clip |
123456 | 654321 | ||
text-overflow: clip ellipsis |
1234… | 6543… | ||
text-overflow: clip '.' |
1234. |
1234567890
|
6543. |
1234567890
|
text-overflow: ellipsis clip |
…3456 | …4321 | ||
text-overflow: ellipsis ellipsis |
…34… | …43… | ||
text-overflow: ellipsis '.' |
…34. |
1234567890
|
…43. |
1234567890
|
text-overflow: ',' clip |
,3456 |
1234567890
|
,4321 |
1234567890
|
text-overflow: ',' ellipsis |
,34… |
1234567890
|
,43… |
1234567890
|
text-overflow: ',' '.' |
,34. |
1234567890
|
,53. |
1234567890
|
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('CSS4 UI', '#text-overflow', 'text-overflow')}} | {{Spec2('CSS4 UI')}} | Added the values <string> and fade and the fade() function |
| {{SpecName('CSS3 UI', '#text-overflow', 'text-overflow')}} | {{Spec2('CSS3 UI')}} | Initial definition |
A previous version of this interface reached the Candidate Recommendation status. As some not-listed-at-risk features needed to be removed, the spec was demoted to the Working Draft level, explaining why browsers implemented this property unprefixed, though not at the CR state.
{{cssinfo}}
{{Compat("css.properties.text-overflow")}}