HTML td with fixed width

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alien
    New Member
    • Sep 2007
    • 61

    HTML td with fixed width

    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.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please show us the code you're using.

    Comment

    • ariful alam
      New Member
      • Jan 2011
      • 185

      #3
      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.

      Code:
      <table>
      	<tr>
      		<td style='width:150px; height:50px; border:1px silver solid'>
      			i love my country Bangladesh.
      		</td>
      		<td style='width:150px; height:50px; border:1px silver solid'>
      			abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
      		</td>
      		<td style='width:150px; height:50px; border:1px silver solid'>
      		</td>
      	</tr>
      </table>

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        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.

        Comment

        • ariful alam
          New Member
          • Jan 2011
          • 185

          #5
          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>

          Comment

          Working...