Reputation: 2877
I found several CSS solutions to display only one line of text in an element whose text content would otherwise occupy several lines. However they don't seem to work when the element is a table cell. Is it impossible to achieve such limitation in a table cell?
Upvotes: 2
Views: 4521
Reputation: 9583
You can do this with using a combo of max-width:
and white-space: nowrap;
: JS Fidle
HTML
<table>
<tr>
<td>content content and a bunch of other stuff.</td>
</tr>
</table>
CSS
td {
max-width: 120px;
white-space: nowrap;
background: #000;
color: white;
}
Upvotes: 3
Reputation: 1207
You could use:
td {
white-space: nowrap;
overflow: hidden;
width: 50px; /* if you'd like the with set' */
}
This limits it to only using one line of text. If you also like to ignore br tags:
td br{
line-height: 0px;
display:none;
}
Upvotes: 2
Reputation: 1062
You should use the property white-space: nowrap;
You can take a look here if you want more information
http://www.w3schools.com/cssref/pr_text_white-space.asp
Upvotes: 0