I want to display text in the table and I want to cut it when it is wider than 150px, but I don't want fixed width of the table cell (if there is no text, width will be 0px). Everything works in IE9, Firefox, Chrome, Opera but not in IE8.
Code example in IE8:
Code example in Chrome:
Here's the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
td, span {
border: 1px solid red;
max-width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
span {
border: 1px solid green;
display: block;
}
</style>
</head>
<body>
<table>
<tr>
<td><span>Works in Firefox, Chrome, Opera, IE 7/9 (but not in IE 8)</span></td>
<td>Works in Firefox, Chrome (and Opera but no dots)</td>
<td style="display: block">Works in Firefox, Chrome and Opera (with dots)</td>
</tr>
</table>
</body>
</html>
It is possible do so without any javascript or setting fixed width?