To stop text wrapping in a table cell (<td>
) or table header cell (<th>
) in HTML, you can use the CSS property white-space
and set its value to nowrap
.
Here's an example of how to apply the white-space
property to a table cell using CSS:
html<style>
td, th {
white-space: nowrap;
}
</style>
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>This is a long sentence that should not wrap</td>
<td>This is another long sentence that should not wrap</td>
</tr>
</table>
In this example, the white-space: nowrap;
CSS property is applied to all table cells and table header cells, which prevents the text from wrapping. You can adjust the CSS selector to target specific cells if needed.
Comments
Post a Comment