View Full Version : how to set the width of colomn inside a table
janunme
04-22-2007, 10:43 AM
hi to all
i want to know how to set the width of column inside a table. i mean to say, in my program i am displaying employee details. inorder to display details i used table. when ever the size of the text more the hight of each coloun increasing. thats why i want to set a fixed size so that all different sizes of texts will fit into that column.
regards
xoblivionxfantasyx
04-29-2007, 04:06 PM
you can try something like this:
<td width="25%">
and just change the percentage to whatever fits your needs
nwalton
04-30-2007, 03:42 PM
Even if you're using a table, it's still best to set the presentational attributes via CSS:
td.details {
width:25%;
}
...
<table>
<tr>
<td class="name">Employee Name</td>
<td class="details">...</td>
</tr>
</table>
You can set the width of the column in both relative and fixed terms. Use % if you want the column to get bigger when the page is resized horizontally (like above).
Use em if you want the column to always stay proportional to the size of the text. (This is often the best if your layout is flexible)-- width:30em;
And use px if you want the column to just stay the same size-- width:250px;
mdcloud
04-30-2007, 05:13 PM
instead of a <td> in the first row, use a <th> you can then assign width to that column
nwalton
04-30-2007, 05:47 PM
Good idea. Then you can also control the look of the header column with your CSS, separately from the style of the rest of the table.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.