How to set seperate heights for <td> ? I have table with one rows and 2 cells. In one of them there is more data, so it drags the other cell longer than it should be and that's ugly. I need something that automatically adjusts the cell height according to how much data it consists. How can I achieve this effect ?

Recommended Answers

All 6 Replies

If you look into using CSS it may help, you can use a fairly simple code on each part of the table.
You can simply assign a class to each row / column to control what the style is a width.

The css for this is as follows, assign the class then place this in the style sheet.

.tablesize
{
width: auto;
height: auto;
}

this should solve your problem, just make sure you do the class on each part of the table, such as

<tr>
    <td class="tablesize">&nbsp;</td>
    <td class="tablesize">&nbsp;</td>
  </tr>

if you dont know how to attach a stylesheet, there are numerous tutorials on this.
Thanks,
Adam

It did not fix my problem.

Check image in attachment, maybe it helps to understand what I need.

This is what I have. I need the second box to be with exact height of how much data it has inside.

Please post code, including CSS, its hard to figure it out without this. Should be able to sort this quicker with the code :)

You can create a parent div that contains 2 child divs. The first child div should be floated left, whilst the other floated right. But, you will have to do some fiddling with CSS to make the children divs remain in the parent.

I had them in divs before but I decided to go with tables cause it seemed to be more cleaner, but I guess I will switch back to divs cause I cant resize cells. Thanks for help guys!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.