CSS text-overflow Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Typography

What You’ll Learn

The text-overflow property controls how overflowing text is shown — using clip or ellipsis when content exceeds its container.

01

Overflow Text

Handle long strings.

02

ellipsis

Show ...

03

clip

Default cut off.

04

overflow

Pair hidden.

05

white-space

Single line.

06

Truncate UI

Cards & nav.

Introduction

The text-overflow property in CSS is used to specify how overflowed content that is not displayed should be signaled to the user. It is particularly useful for handling overflow situations in text elements where the text content exceeds the container’s size.

This property can ensure that long text strings are handled gracefully, either by clipping them or by adding an ellipsis to indicate that the text is longer than the container.

Definition and Usage

Use text-overflow when text must stay inside a fixed-width box such as a sidebar link, table cell, or card title. For the common single-line ellipsis pattern, combine it with overflow: hidden; and white-space: nowrap;.

💡
Beginner Tip

The classic truncation recipe is: overflow: hidden; white-space: nowrap; text-overflow: ellipsis; plus a width or max-width.

📝 Syntax

The syntax for the text-overflow property is simple and can be applied to block containers with overflowed content:

syntax.css
element {
  text-overflow: value;
}

Basic Example

text-overflow.css
.container {
  width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

Syntax Rules

  • text-overflow only affects overflow that is already hidden.
  • Use ellipsis to show ... when text is truncated.
  • Use clip to cut text off cleanly with no indicator.
  • The property is not inherited; apply it to the truncating element itself.

Related Properties

  • overflow — controls whether overflowing content is visible or hidden
  • white-space — prevents wrapping for single-line truncation
  • overflow-wrap — controls how long words break inside containers

🎯 Default Value

The default value of the text-overflow property is clip, meaning the overflowed text will be clipped without any visual indication that there is more text.

⚡ Quick Reference

QuestionAnswer
Default valueclip
Single-line ellipsisoverflow: hidden; white-space: nowrap; text-overflow: ellipsis;
Show ... indicatortext-overflow: ellipsis;
Hide without indicatortext-overflow: clip;
Needs widthYes — set width or max-width
InheritedNo

💎 Property Values

The text-overflow property accepts keyword values and, in some browsers, a custom string.

ValueExampleDescription
cliptext-overflow: clip;This is the default value. The text is clipped to fit the container.
ellipsistext-overflow: ellipsis;Displays an ellipsis (...) to indicate that there is more text than is currently visible.
Custom stringtext-overflow: "…";A string to display to indicate overflow. Note that this is not supported in all browsers.
clip ellipsis

When to Use text-overflow

text-overflow is the right choice when long text must fit a constrained layout:

  • Navigation menus — Truncate long page titles in sidebars.
  • Card titles — Keep product or article names on one line.
  • Tables — Prevent wide cell content from breaking table layout.
  • Responsive UI — Maintain clean layouts on narrow screens.

👀 Live Preview

Compare clip and ellipsis on the same long text string:

clip — This is a very long text that will not fit in the container.
ellipsis — This is a very long text that will not fit in the container.

Examples Gallery

In this example, we’ll use the text-overflow property to add an ellipsis to text that overflows its container.

📜 Basic Truncation

Clip overflowing text or show an ellipsis when content exceeds the box width.

Example 1 — Ellipsis on overflowing text

In this example, we’ll use the text-overflow property to add an ellipsis to text that overflows its container.

index.html
<style>
  .container {
    width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid #000;
  }
</style>

<h1>Text Overflow Example</h1>
<div class="container">
  This is a very long text that will not fit in the container.
</div>
Try It Yourself

How It Works

The container hides overflow, keeps text on one line, and replaces the clipped end with an ellipsis.

Example 2 — clip without an indicator

Use the default clip value when you want overflow hidden without showing ....

clip-overflow.css
.clip-box {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
Try It Yourself

How It Works

Extra text is cut off at the container edge with no visual hint that more content exists.

📄 UI Patterns

Use ellipsis truncation in navigation links and card layouts.

Example 4 — Truncated card title

Prevent long article or product titles from breaking card layouts.

card-title.css
.card-title {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
Try It Yourself

How It Works

The title stays on one line inside the card and truncates with an ellipsis when space runs out.

♿ Accessibility

  • Provide full text elsewhere — Use a title attribute or expandable content so users can access truncated text.
  • Do not hide critical info — Important words should not disappear entirely without another way to read them.
  • Keyboard and screen readers — Truncation is visual; the full text may still be available to assistive tech in the DOM.
  • Avoid over-truncation — Very short containers can make labels meaningless.

The ellipsis truncation recipe

text-overflow works only when overflow is hidden. For single-line truncation, combine it with overflow, white-space, and a width constraint.

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

🧠 How text-overflow Works

1

Text exceeds the box

A fixed or max width limits how much text can fit on one line.

Overflow
2

Overflow is hidden

overflow: hidden; and white-space: nowrap; keep extra text off-screen.

Hidden
3

text-overflow styles the edge

Choose clip or ellipsis for the visible cutoff.

Indicator
=

Clean truncated UI

Long labels fit narrow layouts without breaking the design.

Browser Compatibility

The text-overflow property is widely supported in modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. For best results, always test your design across different browsers to ensure compatibility.

Universal · All modern browsers

Reliable text truncation

Chrome, Firefox, Safari, Edge, and Opera all support text-overflow: ellipsis; in current versions.

99% Browser support
Google Chrome 1+ · Desktop & Mobile
Full support
Mozilla Firefox 7+ · Desktop & Mobile
Full support
Apple Safari 1.3+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 11+ · All versions
Full support

Testing tip

Custom string values for text-overflow have limited support; prefer ellipsis for production UI.

text-overflow property 99% supported

Bottom line: text-overflow: ellipsis; is one of the most reliable CSS patterns for responsive UI truncation.

Conclusion

The text-overflow property is an essential tool for web developers dealing with overflowed text content.

By providing options to clip the text or add an ellipsis, it ensures a clean and user-friendly interface. Experiment with different values to see how this property can improve the readability and aesthetics of your web projects.

💡 Best Practices

✅ Do

  • Use the full truncation recipe: overflow, white-space, and text-overflow
  • Set a width or max-width on the truncating element
  • Use ellipsis when users should know more text exists
  • Provide full text in a tooltip or detail view when needed
  • Test truncation on mobile sidebar and card layouts

❌ Don’t

  • Expect ellipsis without overflow: hidden;
  • Truncate critical information with no way to read the full text
  • Rely on custom string overflow values for cross-browser UI
  • Forget that single-line ellipsis requires white-space: nowrap;

Key Takeaways

Knowledge Unlocked

Five things to remember about text-overflow

Use these points when truncating text in UI layouts.

5
Core concepts
02

clip

Default value.

Default
03

ellipsis

Shows ...

Common
🔒 04

overflow hidden

Required pair.

Rule
05

max-width

Needs a limit.

Layout

❓ Frequently Asked Questions

text-overflow controls how overflowing text is shown when it does not fit its container. Common values are clip and ellipsis.
The default is clip, which cuts off overflowed text without showing an ellipsis or other indicator.
For single-line ellipsis you usually need overflow: hidden, white-space: nowrap, and a width or max-width on the element.
clip simply hides the extra text. ellipsis adds ... to show that more text exists beyond the visible area.
No, text-overflow is not inherited. You must apply it directly to the element whose text should truncate.

Practice in the Live Editor

Open the HTML editor and try the ellipsis truncation recipe on a long paragraph.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful