By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,726 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

HTML td with fixed width

P: 61
Hi
I want to make sure that in my table the columns are fixed width. So if the content of it is very large the column can expand downwards but no across. I have tried using the width attribute with no luck.

How can I achieve this? Thanks.
Aug 12 '12 #1
Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,430
Please show us the code you're using.
Aug 12 '12 #2

ariful alam
100+
P: 185
Ok, see I used same width for the columns in the table in code block. but because of text in the <td></td> block the width gets more width-er than defined. I think there is no solution for this.

Expand|Select|Wrap|Line Numbers
  1. <table>
  2.     <tr>
  3.         <td style='width:150px; height:50px; border:1px silver solid'>
  4.             i love my country Bangladesh.
  5.         </td>
  6.         <td style='width:150px; height:50px; border:1px silver solid'>
  7.             abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
  8.         </td>
  9.         <td style='width:150px; height:50px; border:1px silver solid'>
  10.         </td>
  11.     </tr>
  12. </table>
Aug 13 '12 #3

Rabbit
Expert Mod 10K+
P: 12,430
You could probably do it with the CSS3 max-width style. But my browswer at work doesn't support CSS3 so I can't test it. You could always fake it with divs.
Aug 13 '12 #4

ariful alam
100+
P: 185
As @Rabbit says, max-width can fix the problem. but it rises a new problem. and that is your long text will go outside of the column <td></td>
Aug 13 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.