View Full Version : resizing table cols based on text content

Mar 10th, 2010, 04:58 PM

new here so take it easy on me :)

could anyone tell me how to resize a table column based on its contents?....
i have a table with one row and four cols... ideally i would like to resize the cols with text in them so they only fit the text and then have a number of pixels space to the next image... Can this be done using css? or would i need to have maybe two tables side by side to give me the required number of pixel space between the images and text.
Oh and it has to be in a table

<table >
<td><img src="image1.png" ></td>
<td >Text for Image 1</td>
<td><img src="image2.png" ></td>
<td>Text For image two</td>

Mar 10th, 2010, 05:36 PM
First, what you are asking for is the default behaviour of most (if not all) visual browsers, so why do you need to add CSS? You could use CSS to add extra padding, but if you are not showing borders in your table, there will probably be several pixels between the images and text.

Second, this is not what tables are designed for. Why do you say
it has to be in a table?

BTW, although <tbody> is required, both the opening and closing tags are optional, as are those for <thead>, so <table><tr><td></td></tr></table> is quite valid.

Mar 10th, 2010, 06:32 PM
hey there,

sorry i didnt explain well at all.... i wanted to resize the column so that any additional space after the text is removed..and the next column with the image in it moves closer to the column..

Mar 11th, 2010, 08:48 AM

Mar 11th, 2010, 01:59 PM
Have you created a test file with the exact code for the table you gave in your original post? How does it behave? Does it have extra space around the text? If so what browser are you using to view it?