tags:

views:

528

answers:

7

I have html code like this

<tr class="odd">
    <td><b>Reason for Termination:</b></td>
    <td>this has bunch of reasons like reason 1, reason2, reason3, reason 4, reason 5 etc</td>
    <td></td><td></td>
</tr>

I want the second TD tag to have some sort of predefined word break. so that when the page is loaded there would be an 'end of line', so to speak, after, say, reason 2.

can html be used here?

Edit: I am not referring to <br>. The content loaded into the tr tag is coming dynamically so I wont know where to put the 'br'. I am looking for a way to cut off the text at a given width so that it rolls over to the next line

A: 

The
tag is used for line breaks, as you can see.

That is, the <br> tag.

Also, depending on which type and version of HTML you are using, you may need to use <br />.

Steve Klabnik
+2  A: 

Are you talking about line break?

<br />

Also if you specify a width to that column. It should wrap accordingly.

Ólafur Waage
sorry, was not talking about the br tag. And If i specify width on this TD then all the TD's above are also getting squashed
if this answer doesn't do anything you want, why is it marked as accepted?
rmeador
+10  A: 

You need the <wbr/> tag. It suggests to the browsers where you would like a break to occur. You can insert it anywhere you like, and the text should wrap on that position.

geowa4
Not a standard element.
Mercer Traieste
yeah, but if you follow the link it shows the other alternatives.
geowa4
If you read the asker's edit on the question, this isn't a valid answer in this case.
T Pops
If you read the asker's edit on the question, that is still a perfectly valid answer. He never mentioned that he did not want the wbr tag or its alternatives listed on the page to which I link. RTFQ
geowa4
+1  A: 

You should set the width of the td containing the words to a specific size using css.

Mercer Traieste
A: 

The only way to break a line before it gets to the end of the table cell is to use a <br /> tag.

Since you don't have control over the content, this is impossible to achieve.

T Pops
A: 

As an alternative to the <wbr /> tag you can also wrap the text that needs to stay together (for example the individual reasons) in spans and give the span a

span {
    white-space: nowrap;
}
jeroen
A: 

Style the second <td> with a width.

<tr class="odd">
    <td><b>Reason for Termination:</b></td>
    <td class="reason_width">this has bunch of reasons like reason 1, reason2, reason3, reason 4, reason 5 etc</td>
    <td></td><td></td>
</tr>

and

.reason_width { width: 300px; }

This will wrap the second <td> at 300 pixels.

Curtis Tasker