Click here to Skip to main content
13,867,447 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 25 Nov 2010
Licenced CPOL

Handling long text using TEXT-OVERFLOW : ECLLIPSIS

, 28 Nov 2010
Rate this:
Please Sign up or sign in to vote.
Handling long text using TEXT-OVERFLOW : ECLLIPSIS


  1. I got requirement from the client that if the text is longer than text get truncated and display "..." at the end of the string.
  2. But the twist is I have to display "..." in ASP.NET GridView control for each cell.


I am working on my blog post formatting this day.

I have to display this as

I am working on my blog post formatting this day.


Make use of available CSS property

text-overflow: ellipsis; which truncate text form the point where text is wraping and display "..." as we require to resolve our issue.

Solution for the First Problem

So out css class for DIV element to get "..." will be like:

   border-bottom: 1px solid; 
   border-left: 1px solid; 
   border-right: 1px solid; 
   border-top: 1px solid;        
   overflow: hidden; 
   text-overflow: ellipsis; 
   width: 150px;


I am working on my blog post formatting this day.

This property is that its works for div, p type element. i.e for the block element. So it resolves my first problem.

Solution for the Problem 2

But the CSS text-overflow not working for the html table element directly. And GridView control get converted in table structure when its render on client browser.

So to resolve this issue we have to use another CSS property call

table-layout : fixed; more about table-layout :

table-layout: fixed; 
width: 200px;
table td
overflow: hidden; 
text-overflow: ellipsis;

My WebSite :
My WebSite2 :


text-overflow : ecllipsis is supported by IE6+, Google Chrome


So text-overflow:eclipse reduce the cost of calculating no. char we can display in a given width and write some custom login to display "..." append with the string.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Pranay Rana
Software Developer (Senior)
India India

Microsoft C# MVP (12-13)

Hey, I am Pranay Rana, working as a Team Leadin MNC. Web development in Asp.Net with C# and MS sql server are the experience tools that I have had for the past 5.5 years now.

For me def. of programming is : Programming is something that you do once and that get used by multiple for many years

You can visit my blog

StackOverFlow -
My CV :-


You may also be interested in...


Comments and Discussions

GeneralThe correct value is "ellipsis". You even used it twice in t... Pin
Richard Deeming10-Dec-10 9:12
mveRichard Deeming10-Dec-10 9:12 
GeneralReason for my vote of 5 Extremely Helpful, many thanks Pin
zoetosis6-Dec-10 10:21
memberzoetosis6-Dec-10 10:21 
GeneralHere is the relevant section in the CSS3 specification: http... Pin
Morten Nilsen25-Nov-10 22:12
memberMorten Nilsen25-Nov-10 22:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05 | 2.8.190214.1 | Last Updated 29 Nov 2010
Article Copyright 2010 by Pranay Rana
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid