How to make td (cell) from html table expand for the row to fit in one line?
Asked Answered
D

2

7

In some html cells (td) the text is wrapped because the size of the column is smaller than the size of the text on the cell. I don't want the text to be wrapped, I want the column width to expand so the wrapping don't happen!

How can I do that?

One final note, I only can use html code, no css :(

Damalus answered 1/6, 2012 at 16:6 Comment(2)
I'm not clear on what the problem is. Can you add an example or expand on your question?Lucais
@Lucais I've edit my question, hope you understand now.Damalus
L
11

Since you can't use CSS, how about:

<td nowrap="nowrap">

I'd prefer to use CSS here on the TD (white-space:nowrap) since the nowrap attribute on the TD element isn't supported HTML 4.01 Strict / XHTML 1.0 Strict.

Here's a quick jsFiddle example showing the effect. Take out the attribute and you can see the difference.

Lucais answered 1/6, 2012 at 16:20 Comment(1)
Thanks, it's exactly this :) I'm making code for a email (so plain html only)Damalus
A
13

Confusing question, but I think you might be looking for the colspan="x" attribute.

<table>
   <tr>
      <td>1</td>
      <td>2</td>
   </tr>
   <tr>
      <td colspan="2">fills both columns</td>
   </tr>
</table>
Aerosphere answered 1/6, 2012 at 16:11 Comment(1)
Thanks for the quick answer but I don't want this. I've updated my question, hope you understand it now.Damalus
L
11

Since you can't use CSS, how about:

<td nowrap="nowrap">

I'd prefer to use CSS here on the TD (white-space:nowrap) since the nowrap attribute on the TD element isn't supported HTML 4.01 Strict / XHTML 1.0 Strict.

Here's a quick jsFiddle example showing the effect. Take out the attribute and you can see the difference.

Lucais answered 1/6, 2012 at 16:20 Comment(1)
Thanks, it's exactly this :) I'm making code for a email (so plain html only)Damalus

© 2022 - 2024 — McMap. All rights reserved.