DCSIMG
Text Trimming Using CSS - Zuker On Foundations

Zuker On Foundations

The realm of .NET (WPF, WCF and all around)
Text Trimming Using CSS

There is a non-so-familiar way to apply trimming to text in HTML using simple CSS.

In order to apply a certain width on an element and together ensure that its innerText will be bound to that and will be trimmed accordingly, we can do the following:

<span class="LongTextContainer">Very long text here.. Bla Bla Bla</span>

.LongTextContainer
{
   width: 300px;
   position: fixed;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
}

The text-overflow determines that the text will be trimmed while showing ellipsis in the end.

This seems to do the trick quite perfect.

Read additional information in this post.

Published Thursday, January 15, 2009 3:25 PM by Amir Zuker

תגים:,

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: