---
title: "Why is text-overflow: ellipsis not working?"
description: "text-overflow: ellipsis needs overflow hidden, nowrap and a width limit, and flex children need min-width 0. Also learn how to clamp text to several lines with an ellipsis."
url: https://www.danny.engineering/answer/css/why-is-text-overflow-ellipsis-not-working
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T17:25:00.000Z
tags: ["CSS"]
---

# Why is text-overflow: ellipsis not working?

## The short answer


`text-overflow: ellipsis` does nothing on its own. The text must be on one line, the box must hide its overflow, and the box must have a width it cannot grow past. Inside a flex container you usually also need `min-width: 0`.


```css
.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
```


## Why it happens


`text-overflow` only describes what to draw when inline content overflows its box **and** that overflow is hidden. If any part of that is missing, there is nothing for it to act on:

- **Text wraps.** By default, long text wraps onto a new line, so it never overflows horizontally. `white-space: nowrap` keeps it on one line.
- **Overflow is visible.** With the default `overflow: visible`, the text simply spills out. It needs `overflow: hidden` (or `clip`).
- **The box grows to fit.** An inline element such as a `span` has no width of its own, and a flex item will refuse to shrink smaller than its content. The text then never overflows, because the box keeps getting wider.

The flex case catches most people. Flex items have a default `min-width: auto`, which means "never shrink below the width of my content". A long unbroken line of text therefore pushes the item, and often the whole layout, wider instead of being truncated.


## How to fix it


### Single line on a block element


Apply all three properties to an element that is block or inline-block and has a constrained width:


```css
.title {
  display: block;
  max-width: 20rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
```


If the element is a `span` or `a`, it is inline by default, so add `display: block` or `display: inline-block`.


### Inside a flex container


Add `min-width: 0` to the flex item that holds the text, so it is allowed to shrink:


```css
.row {
  display: flex;
  gap: 1rem;
}

.row__text {
  flex: 1;
  min-width: 0; /* let the item shrink below its content width */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
```


If the text is nested deeper, every flex item between the container and the text may need `min-width: 0`. The same applies to grid items, where `minmax(0, 1fr)` in the track definition does the same job:


```css
.grid {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
}
```


### In a table cell


Table cells grow to fit their content. Give the table a fixed layout and the cell a width:


```css
table {
  table-layout: fixed;
  width: 100%;
}

td.name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
```


### Clamp to several lines


For two or three lines followed by an ellipsis, use line clamping. The prefixed form is the one that works across all current browsers:


```css
.excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
```


Do not add `white-space: nowrap` here, because the text needs to wrap to fill the lines. Despite the `-webkit-` prefix, this is specified for compatibility and is supported in Chrome, Edge, Firefox and Safari.


## Common pitfalls

- **Applying it to the parent instead of the text element.** The properties go on the box that directly contains the overflowing text.
- **Missing** **`min-width: 0`** **in nested flex layouts.** One forgotten level is enough to stop truncation.
- **Padding on the clamped element.** With line clamping, bottom padding can reveal part of the next line. Put the padding on a wrapper instead.
- **Hiding important information.** Truncated text is still in the DOM and read by screen readers, but sighted users cannot see it. Add a `title` attribute or a way to expand the content if the full text matters.
- **Expecting it to work with** **`overflow: auto`****.** Scrollable overflow does not show an ellipsis in a useful way. Use `hidden` or `clip`.

## Related reading

- [MDN: text-overflow](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow)
- [MDN: -webkit-line-clamp](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp)
