Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HTML table question

Posted on 2006-11-10
9
Medium Priority
?
186 Views
Last Modified: 2010-04-09
Hi all,

If a have a table like so:

|COLUMN1|COLUMN2|COLUMN3|COLUMN4|

If say column1 has a value which contains a large amount of text is there a way to wrap the text to a new line every say 50 chars?

So the column's always remains the same width regardless of the amount text within them.

Thanks
0
Comment
Question by:CtrlCtrlV
  • 6
  • 3
9 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 800 total points
ID: 17915984
Use this

<td style="word-wrap:break-word;">
0
 
LVL 33

Expert Comment

by:hongjun
ID: 17915987
You fix the width yourself. This is not by number of characters but is by width
0
 
LVL 33

Expert Comment

by:hongjun
ID: 17915991
E.g.

<table border="1">
<tr>
    <td style="word-wrap:break-word;width:100px">
        Column1Column1Column1Column1Column1Column1Column1Column1Column1Column1Column1Column1
    </td>
    <td>
        Column2
    </td>
    <td>
        Column3
    </td>
    <td>
        Column4
    </td>
</tr>
</table>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:CtrlCtrlV
ID: 17916044

Thats brilliant, thanks a million.

Could you explain to me what <td style="word-wrap:break-word;width:100px"> acually does?

Thanks
0
 
LVL 33

Expert Comment

by:hongjun
ID: 17916070
>> word-wrap:break-word;

Does exactly what you wanted

>> width:100px

This specifies the width of the column in pixels.
You can change this value to your liking.


hongjun
0
 

Author Comment

by:CtrlCtrlV
ID: 17916109

ok, thanks, just one more thing, is it possible to apply
<td style="word-wrap:break-word;width:100px">
to the whole table instead of having to put it in every <td> tag?

thanks again
0
 
LVL 33

Expert Comment

by:hongjun
ID: 17916151
Can.


<style>
td {
      word-wrap:break-word;
      width:100px;
}
</style>

<table border="1">
<tr>
    <td>
        Column1Column1Column1Column1Column1Column1Column1Column1Column1Column1Column1Column1
    </td>
    <td>
        Column2
    </td>
    <td>
        Column3
    </td>
    <td>
        Column4
    </td>
</tr>
</table>



hongjun
0
 

Author Comment

by:CtrlCtrlV
ID: 17916173

thank you ;-)
0
 
LVL 33

Expert Comment

by:hongjun
ID: 17916179
Welcome
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question