You are currently viewing How to display ellipsis after the text using CSS
How to display ellipsis after the text using CSS

How to display ellipsis after the text using CSS

  • Post category:CSS

Do you know How to display ellipsis after the text using CSS?

Get the code of How to display ellipsis after the text using CSS and watch video tutorials. You can practice using our code editor. Our practical guide will make your learning journey much easier. You can explore the tutorial and learn.

<h3>This is a text which i am going to show only single line and then ellipsis should display. means three dots.</h3>
h3 {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: yellow;
  border: 1px solid black;
  padding: 5px;
  font-size: 44px;
}

Ready to become a better coder? Don’t miss this tutorial!: https://mrdigitals.com/how-to-make-buttons-to-smart-button/

How to Display Ellipsis After Text Using CSS

Sometimes, text on a website is too long to fit inside its available space. This can make cards, navigation menus, product listings, and other interface elements look crowded or unorganized. One simple solution is to display an ellipsis (…) at the end of the text to indicate that some content has been hidden.

CSS makes this possible without changing the original text. By using the text-overflow property, developers can create a clean layout while keeping long text from overflowing its container.

What Is an Ellipsis in CSS?

An ellipsis is a series of three dots that indicates omitted or shortened content. In web design, it is commonly used when a text element has limited space.

For example, a long product title might be shortened to “Premium Wireless Headphones for…” rather than extending beyond its card. Similarly, a blog description can display only part of its content to maintain a consistent layout.

This technique is especially useful when displaying many items in a grid or list where each element needs to have a similar size.

How Does the CSS Text Overflow Property Work?

CSS provides the text-overflow property to control how overflowing text is represented. One of its most common values is ellipsis, which displays an ellipsis when text extends beyond the available space.

However, this property does not work independently in every situation. For a typical single-line ellipsis, developers generally need to prevent the text from wrapping, hide the overflowing content, and define a limited width for the container.

These settings work together to keep the text on one line and show the ellipsis when it no longer fits.

For multiple lines of text, CSS can use a different approach that limits the visible content to a specified number of lines. This is useful for article summaries, product descriptions, and preview cards.

Benefits of Using Ellipsis in Web Design

Cleaner layouts: Long text can be shortened visually, helping cards and lists maintain a consistent appearance.

Better space management: Ellipsis is useful when a page has limited room for titles, descriptions, or labels.

Improved readability: Users can scan important information without seeing lengthy text in every section.

Consistent design: Product cards, blog previews, and search results can maintain similar dimensions even when their text lengths differ.

Flexible styling: Developers can apply text truncation to different elements depending on the design requirements.

Common Uses of CSS Ellipsis

Ellipsis is often used in online stores to keep product names within a fixed card width. It is also useful for blog listings, where article titles and summaries need to fit into a structured layout.

Navigation menus can benefit from text truncation when space is limited, although important navigation labels should remain understandable. Dashboard interfaces may also use ellipsis to display long file names, user-generated titles, or table values.

For multi-line text, limiting a description to two or three lines can help maintain a balanced design while giving users a quick preview of the content.

Tips for Creating a Better Ellipsis Effect

First, choose a suitable width for the text container. If