samuel
samuel

Reputation: 99

How to make the table text never break line?

This is kind a newbie question.

In table cell, if the text is long, how do I make the texts shows in one line ? Never break the line.

The TABLE and TD widths are depends how text long automatically calculated.

For example:

table, td {width: auto}
<table border=0>
  <tr>
    <td>text text text  text  text  text  text  text  text  text  text  text text text text text text text text text</td>
  </tr>
</table>

Upvotes: 0

Views: 74

Answers (3)

Praveen Poonia
Praveen Poonia

Reputation: 765

use this -

<style>
table, td {width:auto; white-space: nowrap; overflow-x: scroll; }
</style>

Upvotes: 0

connexo
connexo

Reputation: 56813

Just apply white-space: nowrap; on the td elements:

<table border=0>
<tr>
  <td>text text text  text  text  text  text  text  text  text  text  text text text text text text text text text</td>
</tr>
</table>

<style>
table, td {width:auto; white-space: nowrap; }
</style>

Upvotes: 0

itodd
itodd

Reputation: 2373

You need to use the white-space property on td to stop the text wrapping like so:

td {
  white-space: nowrap;
}

Upvotes: 2

Related Questions