{"id":270438,"date":"2018-05-17T06:57:42","date_gmt":"2018-05-17T13:57:42","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=270438"},"modified":"2021-12-28T12:22:10","modified_gmt":"2021-12-28T20:22:10","slug":"block-overflow","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/b\/block-overflow\/","title":{"rendered":"block-overflow"},"content":{"rendered":"\n
The The property has been introduced in the Editor’s Draft of the CSS Overflow Module Level 3 specification<\/a>. That means it’s experimental at the moment and considered a work in progress. In fact, you can follow the conversation<\/a> which includes chatter about renaming the property altogether.<\/p>\n\n\n Again, all of this is experimental, in-progress work. These values could change. Or, more could be added. For example, there have been calls for a “smarter” ellipsis that might be capable of doing more things, like cropping text in the middle:<\/p>\n\n\n\n We can get just about the same thing using As it’s currently defined, though, None at the moment, but you can get some support using the WebKit’s proprietary implementation of This browser support data is from Caniuse<\/a>, which has more detail. A number indicates that browser supports the feature at that version and up.<\/p><\/div>block-overflow<\/code> property truncates text and indicates more content follows by inserting an ellipsis or custom string after a number of lines that is set by the
max-lines<\/code> property.<\/p>\n\n\n\n\n\n\n\n
Syntax<\/h3>\n\n\n
.module {\n block-overflow: [clip | ellipsis | ];\n max-lines: []; \/* required by block-overflow *\/\n}<\/code><\/pre>\n\n\n\n
block-overflow<\/code> accepts the following values:<\/p>\n\n\n\n
clip<\/code>: Does not insert a character to indicate more text to follow. Instead, the content is merely truncated and cut off at the last character.<\/li>
ellipsis<\/code>: Displays an ellipsis (…) at the end of the last line. It should render as a Unicode character (U+2026) but could be replaced by an equivalent based on the content language and writing mode of the User-Agent being used.<\/li>
<string><\/code>: Displays custom text (e.g. “Read more \u2192”) at the end of the last line. The spec says that the User-Agent may replace the string with an ellipsis if the string is “absurdly” long.<\/li><\/ul>\n\n\n\n
One thing led to another and \n... \nyada yada yada, that was that.<\/code><\/pre>\n\n\n
Use
line-clamp<\/code> for short<\/h3>\n\n\n
line-clamp<\/code><\/a> which is shorthand for the
block-overflow<\/code> and
max-lines<\/code> properties.<\/p>\n\n\n\n
line-clamp<\/code> only accepts a single numeric value for
max-lines<\/code> and implicitly sets
block-overflow<\/code> to the
ellipsis<\/code> value. So, if you want to use a custom string for truncation, then you gotta go with the long form instead.<\/p>\n\n\n
Browser Support<\/h3>\n\n\n
line-clamp<\/code>:<\/p>\n\n\n
Desktop<\/h4>