{"id":14119,"date":"2011-09-06T18:49:17","date_gmt":"2011-09-07T01:49:17","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14119"},"modified":"2014-03-28T08:59:47","modified_gmt":"2014-03-28T15:59:47","slug":"text-overflow","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/t\/text-overflow\/","title":{"rendered":"text-overflow"},"content":{"rendered":"

The text-overflow<\/code> property in CSS deals with situations where text is clipped when it overflows the element’s box. It can be clipped (i.e. cut off, hidden), display an ellipsis (‘\u2026’, Unicode Range Value U+2026) or display an author-defined string (no current browser support for author-defined strings).<\/p>\n

.ellipsis {\r\n  text-overflow: ellipsis;\r\n\r\n  \/* Required for text-overflow to do anything *\/\r\n  white-space: nowrap;\r\n  overflow: hidden;\r\n}<\/code><\/pre>\n

Note that text-overflow<\/code> only occurs when the container’s overflow<\/code><\/a> property has the value hidden<\/code>, scroll<\/code> or auto<\/code> and white-space: nowrap;<\/code>.<\/p>\n

Text overflow can only happen on block or inline-block level elements, because the element needs to have a width in order to be overflow-ed. The overflow happens in the direction as determined by the direction<\/a> property or related attributes. <\/p>\n

The following demo displays the behavior of the text-overflow<\/code> property including all the possible values. Browser support varies!<\/p>\n

<\/code>Check out this Pen!<\/a><\/pre>\n

Setting overflow<\/code> to scroll<\/code> or auto<\/code> will display scrollbars to reveal the additional text, while hidden<\/code> will not. The hidden text can be selected by selecting the ellipses.<\/p>\n

Old Stuff<\/h3>\n

An old version of the spec<\/a> says you could use an URL to an image for the ellipsis, but it looks as if that was dropped.<\/p>\n

There is a two-value syntax, e.g. text-overflow: ellipsis ellipsis;<\/code>, that would control the overflow on the left and right sides of the same container. I’m not sure how that would be possible to achieve. Perhaps centered text in a too-small container? The new spec<\/a> says this, as well as defining a string, is “at risk.”<\/p>\n

I’m not sure where ellipsis-word<\/code> came from. It’s not in the spec or in any other documentation other than on WebPlatform.org<\/a>.<\/p>\n

The text-overflow<\/code> property used to be <\/em>shorthand for the combination of text-overflow-mode<\/code> and text-overflow-ellipsis<\/code>, but not anymore and those separate properties don’t exist.<\/p>\n

Related Properties<\/h3>\n