We know how to write css for Div line breaks and non-line breaks. But for table cells, we only know one attribute, nowrap, which can prevent it from wrapping. I have had this need recently, but I found that adding nowrap will still cause line breaks in some cases! Unfortunately, is there no way to force no line breaks?
How to use CSS to realize automatic line wrapping or non-wrapping of Table cell data:
1. Forced line break:
<style type="text/css">
.AutoNewline
{
word-break: break-all;/*required*/
}
</style>
<table>
<tr>
<td class="AutoNewline">
automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap automatic line wrap
</td>
</tr>
</table>
2. Force no line breaks:
<style type="text/css">
.NoNewline
{
word-break: keep-all;/*required*/
}
</style>
<table>
<tr>
<td class="NoNewline">No line break, no line break, no line break, no line break, no line break, no line break, no line break, no line break, no line break, no line break</td>
</tr>
</table>