Wooden tray of vintage letterpress type blocks arranged in compartments

CSS text-overflow Strings: Smarter Ways to Truncate Text

Every web designer has met the long product name, the endless file name or the headline that simply refuses to fit its box. For years the only tidy fix was a trailing ellipsis. Now the humble text-overflow property can do far more, because browsers are finally agreeing to let you choose the exact characters that mark a cut-off.

Metal printing type sorted into the compartments of a wooden case

By the numbers: who supports it?

  • Firefox has handled custom strings since 2011, so this is not a new idea, just a long-delayed one.
  • Chrome 157 has now shipped the feature.
  • Safari 27.3 includes it in its beta, which points towards the feature becoming Baseline soon.
  • The two-value version, which marks both ends of a scrollable line, works only in Firefox for now.

In practice that means the single-string version is safe to use today as a progressive enhancement. Browsers that do not understand it will simply fall back to the usual behaviour.

How a custom truncation string works

Four things must be true before any truncation happens. The text needs a container with a fixed size in the reading direction, wrapping must be switched off with white-space: nowrap, the overflow must be set to anything other than visible, and the text must actually be too long to fit. Once those boxes are ticked, you can give text-overflow a quoted string instead of the ellipsis keyword, and the browser appends that string where the line is cut.

That string can be an em dash, a bracketed marker such as an editorial omission, or even an empty pair of quotes. The empty version is quietly useful: it trims the overflowing characters without adding anything, so you avoid the half-visible letter that the default clip behaviour can leave at the edge of a box. Tables, file lists and compact cards are the obvious places to try it.

Go Ad Free
Composed block of letterpress type ready for printing

Choosing the right marker

The goal is to make it obvious that something has been shortened. An em dash suggests an abrupt interruption, while a bracketed ellipsis reads as a deliberate omission. Words such as “read more” are tempting but misleading, because the string is plain text and cannot be clicked. If the design needs an expand control, make the whole element respond to hover or focus and keep the marker as a hint rather than a button.

Myths versus facts

Myth: it works on paragraphs. Fact: it is for a single line only. Multi-line text needs line-clamp instead, which can trim the last line but not the first.

Myth: the string is a link. Fact: it is generated text, so it cannot be clicked, selected or animated.

Myth: it behaves the same while people edit or scroll. Fact: scrolled elements and focused, editable fields fall back to clipping so users can see everything they are interacting with, although browsers may differ on the details.

Myth: the ellipsis is going away. Fact: it stays as a keyword. The new option simply gives you more choice, and a fading effect is also on the way in the draft specification for those who prefer a softer edge.

Assorted wooden stamps laid out on a surface

A real-world example for your own site

Imagine a membership site with a directory of local businesses in a narrow sidebar. Some names are short, others run to a full line of text. With a plain ellipsis, every cut-off looks identical. With a custom marker, you could end the line with a dash for names and use an empty string for file downloads, where a clean edge looks tidier than punctuation. It is a small touch, but it makes interface text feel considered rather than accidental.

Go Ad Free

If you build or maintain websites for clients on either side of the Channel, it is worth adding to your toolkit now, with the standard ellipsis as the safety net. When your clients’ customers browse on the latest Chrome or Safari, they will see the improved version without you changing a thing.

Go Ad Free

Create a free account, or log in.

Gain access to read this article, join developers who build better, faster, smarter solutions

Yes! I would like to receive new content and updates.

Scroll to Top