Skip to main content

Cross-Browser CSS Standards Advance as Chrome and Safari Adopt Custom String Text-Overflow Truncation

Web developers are moving closer to universal browser support for one of CSS’s long-standing missing capabilities: the ability to define custom text truncation markers using text-overflow: <string>. With Google officially implementing the feature in Chrome 157 and Apple introducing support in the Safari 27.3 Beta release, the web ecosystem is preparing for string-based text truncation to achieve Baseline status across all major rendering engines.

The milestone comes more than a decade after Mozilla first introduced support for custom truncation strings in Firefox 9 back in 2011. For years, web developers seeking custom inline truncation were forced to accept the standard single-character ellipsis (…) or rely on JavaScript workarounds. The convergence of modern browser implementation now unlocks granular control over single-line text truncation natively within CSS stylesheets.

To understand the significance of custom string values, it helps to examine how text truncation operates within the CSS layout engine. Traditionally, the text-overflow property provided two primary values: clip and ellipsis. The default value, clip, truncates overflowing content precisely at the edge of the line box, often slicing directly through characters and leaving partial glyphs visible. By contrast, text-overflow: ellipsis appends a standardized horizontal ellipsis character, suppressing as many characters as necessary from the end of the text string to accommodate the symbol within the available layout space.

The introduction of text-overflow: <string> expands this system by allowing developers to specify arbitrary string literals—such as an em dash ("—"), custom bracketed text, or contextual indicators—which are rendered in place of truncated characters.

For text-overflow: <string> to take effect, specific CSS layout conditions must be met. First, the text content must overflow its block container along the inline axis. In a standard horizontal layout (writing-mode: horizontal-tb), the inline axis corresponds to the physical element width. Developers typically declare an explicit inline boundary using logical sizing properties, such as inline-size: 170px.

Second, text wrapping must be explicitly suppressed using white-space: nowrap. This constraint forces all inline text onto a single line, ensuring that any content exceeding the container width triggers an overflow state. Because text-overflow operates strictly on single-line layout boxes, multi-line truncation requires different property specifications, such as line-clamp.

Third, the element’s overflow property (or logical overflow-inline) must be configured to any valid value other than visible. When combined with a custom string value—such as text-overflow: "—"—the rendering engine clips the overflowing text and appends the specified string to the end of the line box.

<!-- Block container -->
<div>This text is overflowing its container.</div>
div 
  /* Size */
  inline-size: 170px;

  /* Prevent wrapping */
  white-space: nowrap;

  /* Hide any overflow */
  overflow-inline: hidden;

  /* Append string */
  text-overflow: "—";

Notably, the specification also supports empty string values (text-overflow: ""). This allows developers to truncate overflowing text without replacing it with any visual character. Unlike the default text-overflow: clip value, which can leave fractional characters exposed at the container edge, an empty string ensures that any character overflowing the boundary is hidden entirely.

What should the string be?

The primary design goal when using custom truncation strings is establishing clear visual cues that signal to users that text content has been cut short. Selecting an appropriate string requires balancing typographic conventions with user interface expectations.

An em dash ("—") represents a natural choice for narrative cut-offs, reflecting traditional typesetting practices where em dashes indicate interrupted dialogue or abrupt stops. While declaring a literal ellipsis string ("…") behaves identically to the keyword text-overflow: ellipsis, developers can employ bracketed variations such as "[…]" to denote editorial omissions or curated excerpts within quoted text.

In editorial and content management applications, alternative bracketed strings such as "[truncated]", "[excerpt]", "[sic]", or "[snip]" provide explicit structural context regarding why text is incomplete. However, web design standards caution against using string combinations that mimic interactive elements, such as "[read more]". Because text appended via text-overflow is purely decorative layout content rendered by the user agent, the string itself cannot accept pointer events, focus states, or click listeners. Presenting static truncation strings as interactive affordances can create confusing user experiences.

Designers can nevertheless combine custom strings with user interaction states to create dynamic disclosure patterns. For instance, developers can use indicator strings such as carets ("▲") or chevrons ("⌄") to signal that additional text exists beyond the container bound, while toggling properties when users interact with the element:

<div>Hover this container to reveal the full text.</div>
div 
  /* Size */
  inline-size: 170px;

  &:not(:hover) 
    /* Prevent wrapping */
    white-space: nowrap;

    /* Hide any overflow */
    overflow-inline: hidden;

    /* Append string */
    text-overflow: "▲";
  

Under this approach, hovering over the container restores standard text flow and reveals the complete sentence. Developers should note, however, that text truncation state changes cannot be animated or smoothly interpolated using CSS transitions, nor can they be animated via modern primitives like @starting-style.

There’s a two-value syntax too

Beyond single-line trailing truncation, the CSS Overflow Module defines an advanced two-value syntax for text-overflow that addresses bidirectional content overflow. While single-value declarations target the trailing edge of a line box, the two-value syntax allows developers to define distinct markers for both the start and end of inline text blocks: <inline-start> and <inline-end>.

This two-value syntax becomes functional when applied to scrollable inline containers—specifically those configured with overflow-inline: scroll or overflow-inline: auto. In these scrollable contexts, text can potentially overflow on both sides of the visible viewport depending on the user’s scroll position.

<!-- Block container -->
<div>Hey, scroll this container.</div>
div 
  /* Size */
  inline-size: 170px;

  /* Prevent wrapping */
  white-space: nowrap;

  /* Hide any overflow, allow scrolling */
  overflow-inline: scroll;

  /* <inline-start> <inline-end> */
  text-overflow: "///" ellipsis;

In this implementation, the rendering engine evaluates content position dynamically. The <inline-start> value—represented in the example by three forward slashes ("///")—appears at the leading edge of the container if text has been scrolled past the start boundary. Simultaneously, the <inline-end> value (ellipsis) appears at the trailing edge if additional content remains off-screen to the right. If the container is scrolled to a midpoint where text overflows in both directions, both visual markers render concurrently.

Currently, browser support for the two-value syntax remains limited, with Firefox being the sole rendering engine to implement the full dual-marker specification. Other major browser engines have focused their initial rollout on single-value string parameters.

Across all implementations, specific interactive states automatically override text-overflow formatting. Elements currently undergoing active user scrolling, as well as focused form controls or editable content blocks, temporarily fall back to text-overflow: clip. This automatic adjustment ensures that users editing text or navigating scroll containers maintain complete visibility of characters without decorative truncation symbols obscuring active edit points, though exact fallback behavior can vary subtly across underlying browser engines.

Where to next?

The broader adoption of text-overflow: <string> represents one step in an ongoing effort by the CSS Working Group to modernize text boundary management across web applications. As browser engines complete baseline support for string values, future layout specifications are targeting richer visual overflow effects.

One development on the standards horizon is the addition of fading overflow effects through the text-overflow: fade() function and text-overflow: fade keyword. Designed to create smooth visual transitions at line boundaries, fade(1em) will progressively reduce text opacity over a specified length starting 1em before the edge of the line box. Similarly, percentage-based arguments such as fade(10%) will initiate a linear opacity fade across the final portion of the inline container, reaching complete transparency at the physical edge. The parameterless fade keyword delegates the calculation distance to user-agent defaults.

These advancements complement existing multi-line clamping techniques governed by the line-clamp specification. While text-overflow operates strictly on single-line containers along the inline axis, line-clamp addresses multi-line text blocks by truncating content at a specified line count threshold. However, functional differences remain between the two specifications: line-clamp is restricted to truncating the final line of multi-line blocks, cannot apply truncation to leading content lines, and currently does not support gradient fade functions like fade().

Furthermore, native support for logical properties within text-overflow ensures automatic adaptability to internationalization. Single-value string declarations automatically adjust their positioning based on the document’s computed direction and writing-mode, aligning correctly to right-to-left (RTL) or left-to-right (LTR) inline edges without requiring custom conditional CSS rules.

As Chrome 157 reaches broad stable distribution and Safari completes its beta cycle, web developers can rely on standard interoperability for custom truncation strings. Together with ongoing progress on multi-line clamping standards and progressive fading effects, these layout capabilities provide front-end engineers with expanded toolsets for managing dynamic text content across modern web platforms.

Raul Delapena Setiawan

Author at DesignEnt.

Flash News