Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to truncate HTML String keeping fixed column size

Tags:

html

css

How can the fixed column width could be respected even when the strings are too long?

The thing is that I want to present a report in a jsp, but I separate the headers in a table and the content in another table, giving them both the same width to its columns. The problem is that the text in several columns is too long, so I want to know if it is possible to simply truncate the String to avoid the column from getting bigger.

I would appreciate your help.

like image 604
user1084509 Avatar asked Dec 31 '25 05:12

user1084509


1 Answers

You could try text-overflow: ellipsis:

td {  
  white-space: nowrap;                      
  overflow: hidden;              /* "overflow" value must be different from "visible" */    
  text-overflow: ellipsis;  
}  

Warning: Older versions of IE do weird things if you don't set explicit widths on your columns,

like image 111
robertc Avatar answered Jan 07 '26 09:01

robertc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!