Solved

HTML table question

Posted on 2006-11-10
9
176 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now