CSS

🎯 CSS text-overflow Property

The text-overflow property controls how overflowing text is displayed when it does not fit inside its container.

It is commonly used to truncate long text and replace it with an ellipsis (...).

🔹 Basic Usage

CSS

p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
                

➡️ This prevents wrapping, hides overflow, and adds “...” when text is too long.

🔸 Values

Value Description
clip Cuts off text without adding dots
ellipsis Replaces overflow with “...”
initial Resets to default behavior
inherit Inherits value from parent element

🧩 Examples

clip example:

CSS

p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
                

➡️ Output: text is cut off directly without dots.

ellipsis example:

CSS

p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
                

➡️ Output: Lorem ipsum dolor sit amet...

💡 Summary

  • 🧠 In Short

  • The text-overflow property controls how hidden overflow text is displayed.
  • It works together with white-space: nowrap and overflow: hidden.
  • The most commonly used value is ellipsis for clean UI truncation.