Can anyone give a CSS example of how can I create a table where long texts are truncated to texts ending with “…”?
Here is the example: http://jsfiddle.net/NpABe/
<table>
<tr>
<td>aaaa</td>
<td>ssssssss</td>
<td>dddddddddddd</td>
</tr>
<tr>
<td>ffffffffffffffff</td>
<td>gggggggggggggggggggg</td>
<td>hhhhhhhhhhhhhhhhhhhhhhhh</td>
</tr>
<tr>
<td>jjjjjjjjjjjjjjjjjjjjjjjjjjjj</td>
<td>kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk</td>
<td>llllllllllllllllllllllllllllllllllll</td>
</tr>
</table>
Use
text-overflow: ellipsis. You will need to fix the width of the cells and prevent line wrapping:EDIT: actually this won’t work. It seems you need a container div to apply the styles to:
And then:
EDIT 2 Ah there is a way, but only if you use
table-layout: fixed: