Quick Table Question

C++, C#, Java, PHP, ect...
Post Reply
Alexx
Posts: 23
Joined: Sun Jul 26, 2009 3:39 am

Quick Table Question

Post by Alexx »

Is anyone good with getting text inside a table to break to a new line once it hits the edge of the table? Trying all sorts of ways and having no luck :/

Making a profile system where you could like type in a little 'player description' about yourself in one of the tables but it just keeps widening the table width making it look ugly lol.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Quick Table Question

Post by Jackolantern »

If you are wanting to allow the user to type in the text, it sounds like you need to use a form and implement a "text area" form element.
The indelible lord of tl;dr
Falken
Posts: 438
Joined: Fri May 08, 2009 8:03 pm

Re: Quick Table Question

Post by Falken »

Just limit the width of each table cell, then it will automatically linebreak text and not widening the cell.

Code: Select all

<table>
   <tr>
      <td>Name: </td>
      <td style="width: 200px;">My loooooooooooong name</td>
   </tr>
   <tr>
      <td>Description:</td>
      <td style="width: 200px;">A nice very long description here which linebreaks if the cell is wider than 200pixels!!! MORE TEXT MORE TEXT MORE TEXT</td>
   </tr>
</table>
Or you could just write in your CSS file if you got one:

Code: Select all

td
{
   width: 200px;
}
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
Alexx
Posts: 23
Joined: Sun Jul 26, 2009 3:39 am

Re: Quick Table Question

Post by Alexx »

Falken wrote:Just limit the width of each table cell, then it will automatically linebreak text and not widening the cell.

Code: Select all

<table>
   <tr>
      <td>Name: </td>
      <td style="width: 200px;">My loooooooooooong name</td>
   </tr>
   <tr>
      <td>Description:</td>
      <td style="width: 200px;">A nice very long description here which linebreaks if the cell is wider than 200pixels!!! MORE TEXT MORE TEXT MORE TEXT</td>
   </tr>
</table>
Or you could just write in your CSS file if you got one:

Code: Select all

td
{
   width: 200px;
}
Bah, I know I tried setting the width a few times...was confused why it wouldn't work lol. Thanks for the help bro, I copied yours and it works smoothly now :)

I need to stop coding late at night, hehe. ;)
Post Reply

Return to “Coding”