Welcome to WindowsClient.net | Sign in | Join

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.

Posted: Jul 29 2008, 02:44 PM by zuker | with no comments
Filed under:

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required) 

Page view counter