?
Solved

HTML table question

Posted on 2006-11-10
9
Medium Priority
?
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
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 add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

719 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