2 Simple ways you can truncate text using CSS
CSS Tricks on how to truncate text.

I am a Front end developer currently working on React JS, HTML, CSS, Python, Vue JS, Webpack, Babel, AEM etc.
Search for a command to run...
CSS Tricks on how to truncate text.

I am a Front end developer currently working on React JS, HTML, CSS, Python, Vue JS, Webpack, Babel, AEM etc.
Are you planning to start your coding journey?. Then this is for you - a roadmap to help you achieve your goals.

7 ways in which you can add files to your commit using git add

As a website user, one would have come across links or buttons which say "Click to download" or "Download" on a website. Have you ever wondered how can you add one to your website?. Keep reading!!!. As part of this blog let us see how one can crea...

Display Hello World and custom message using two-way data binding

Build a random quote generator using an API - JavaScript

Kritika Pattalam Bharathkumar | Web Developer - The official blog of Kritika Pattalam Bharathkumar
22 posts
Front End Engineer | Writes about HTML, CSS, JavaScript and everything related to web development | Follow me on Twitter let's chat.
As part of this blog lets see two ways in which you can truncate a text using CSS
.truncate-ellipsis {
width: 350px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: block;
}
With text-overflow , ellipsis can be applied to single line of text, provided the following conditions are met. [ For truncating after multiple lines, keep reading 😉 ].
width , max-width or flex-basis(if using flex)
word-wrap: nowrap
eg: overflow: hidden;
eg: display: inline-block;
Did you know that you can reverse the direction of the truncation using the CSS direction property?
direction: rtl; //show from right to left
The direction property will truncate the text in the start of the line and show the end of the paragraph instead.

.truncate-line-clamp {
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
width: 250px;
overflow: hidden;
}
With line-clamp text can be truncated after multiple lines, whats even more interesting is you can truncate it by specifying the line number where you want to truncate it. eg: -webkit-line-clamp: 3; will truncate start truncating the text from the third line.
Below are the list of conditions which should be met in order to make this work.
eg: display: -webkit-box;
eg: webkit-line-clamp: 3;
eg: -webkit-box-orient: vertical;
eg: overflow: hidden;
Browser Compatability: webkit-line-clamp at the moment is not supported in IE. For detailed information refer: caniuse.com
The below codepen will show you a live preview of the above two methods will look.
Lets connect on Twitter | LinkedIn for more web development related chats.