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.
Fundamentals
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.
Foundation
📝 Syntax
The syntax for the text-overflow property is simple and can be applied to block containers with overflowed content:
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
Defaults
🎯 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.
The text-overflow property accepts keyword values and, in some browsers, a custom string.
Value
Example
Description
clip
text-overflow: clip;
This is the default value. The text is clipped to fit the container.
ellipsis
text-overflow: ellipsis;
Displays an ellipsis (...) to indicate that there is more text than is currently visible.
Custom string
text-overflow: "…";
A string to display to indicate overflow. Note that this is not supported in all browsers.
clipellipsis
Context
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.
Preview
👀 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.
Hands-On
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><divclass="container">
This is a very long text that will not fit in the container.
</div>
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.
Compatibility
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 Chrome1+ · Desktop & Mobile
Full support
Mozilla Firefox7+ · Desktop & Mobile
Full support
Apple Safari1.3+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera11+ · All versions
Full support
Testing tip
Custom string values for text-overflow have limited support; prefer ellipsis for production UI.
text-overflow property99% supported
Bottom line:text-overflow: ellipsis; is one of the most reliable CSS patterns for responsive UI truncation.
Wrap Up
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.