Solved

HTML table question

Posted on 2006-11-10
9
180 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 200 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
Technology Partners: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

685 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