Forum Moderators: open
I'm doing this three column layout (middle column contains nested tables, entire layout uses px- not %, no heights have been defined), and the two side columns happen to have about 1200 vertical pixels of content. So, why is my center column(which is only about 500px worth of content in height) stretching all its containers to cover that 1200px area? I've plastered the infamous "valign=top" about everywhere you could put it, and nothing's changing.
It's obviously some relation to the side columns because if i cut them down to like 300px of vertical content, the page looks fine and dandy.
what the hay?
If a table has three columns, they will all be the same height. Always.
So if one column acquires more content, making it stretch taller, the other two will "keep up" or match it. Automatically. Cool, huh? So much simpler to line up a design.
Now there are games you can play with colspan or combinations of tables to mimic CSS stuff, but if you're too elegant for the slums, why play there?
I'm not trying to mimic divs at all. It had become my understanding that the table behavior you speak of applied only to the remainder areas of cells. It seems much less reasonable to me for a cell to spread out its entire content area than for it to simply add space where there is no content.
My thinking was that if the center column was pink, then the pink background would indeed stretch to 1200px... that's fine and makes sense to me. But why should my content inside that column, which has specifically been told to have a top margin and padding of zero, and have the magical valign=top, be pushed downwards at all, ever, for any reason?
I had forgotten about the colspan attribute... but if my side columns are 1200px long and only take up one column of space, I don't see that helping... I suppose the advice here to is to divvy up those 1200px columns into smaller columns, which I could then reference when i apply colspans to the center content?
Also are you hand-coding the tables? Are you using XHTML or HTML syntax, and does it validate? Don't forget that in HTML the
</td> is iptional so a page can validate as HTML but it has "extra" cells because there is a <td> instead of a </td>. Generally-speaking, if you use
valign="top" then the text should stay at the top of the cell, with empty space underneath to the length of the longest cell.
The code and doctype are 4.01 Trans, and the only types of validation errors (though there are many) are ALT attributes missing and invalid characters in URL structures (affiliate links as you may know are often a bit unreasonable). I used a WYSIWYG to draw the table, and then went into the HTML to get rid of the wackiness. The way the table was generated could of course be the issue... if so, I apologize. I don't usually use WYSIWYG editors either.
I'm not sure if i'm helping or hurting by posting this code after my attempts to take out the piles of specific info in it... but here she be. The sections of thumbnails, along with one or two free-standing banner images also contained in the center, are the items that are being spaced out to the end of eternity. Again, I don't see this problem when there is a small amount of content in the sidebars (the 180px columns)... only when those columns grow to a length longer than the center. Thanks again for any help.
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="860" valign=top>
<tr>
<td colspan="3" height="150">
<img src="-" style="margin: 0; padding: 0; border: 0;">
</td>
</tr>
<tr>
<td width="180" rowspan="5" style="text-align: right;" valign=top>
<img src="-">
<ul>
</ul>
</td>
<td width="500" style="text-align: center; height: 70px;" valign=top>
<h1 style="height: 70px; margin: 0;"></h1>
</td>
<td width="180" rowspan="5" style="text-align: left" valign=top>
<img src="-">
<ul>
</ul>
</td>
</tr>
<tr>
<td width="500" valign=top>
<div align="center" style="padding: 0 15px 0 15px;">
<table border="0" cellpadding="0" cellspacing="0" width="470" valign=top>
<tr>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
</tr>
<tr>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td><img src="-" style="width: 470px; height: 60px; border: 0; padding: 20px 0 20px 0; text-align: center;">
</td>
</tr>
<tr>
<td width="500" valign=top>
<div align="center" style="padding: 0 15px 0 15px;">
<table border="0" cellpadding="0" cellspacing="0" width="470">
<tr>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
</tr>
<tr>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
<td><img src="-"></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td width="500"></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
</table>
</center>
</div>
Have you tried setting BORDER="1" in the TABLE tag... that will show borders and let you see what is where.
Another setting that could be affecting the layout (if it's all IMG tags) is to explicitly set the HSPACE= and VSPACE= paramters on the IMG tags...
Do you want all the images clustered at the top of the page? Grouped 3 across and they shift to 1 across? Are there huge gaps between rows?
What's the mess look like?
rowspan and colspan going on, if you are going down the tables route then you might as well do a simple one table layout and nest a second table in the center column for the content. Something like this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test template</title>
</head>
<body>
<!-- BEGIN outer table -->
<table border="1" cellpadding="0" cellspacing="0" width="860" align="center" style="background-color:#eef;">
<tr>
<td colspan="3" height="150">
<p>top section</p>
</td>
</tr>
<tr>
<td width="180" valign="top">
<p style="margin-bottom:1000px;"><img src="image.jpg" alt="">left column</p>
</td>
<td width="500" valign="top">
<h1>h1 here</h1>
<!-- BEGIN inner table -->
<table border="1" cellpadding="0" cellspacing="0" width="470" align="center" style="background-color:#fee;">
<tr>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
</tr>
<tr>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
</tr>
<tr>
<td colspan="5"><img src="image.jpg" width="470" height="60" alt=""></td>
</tr>
<tr>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
</tr>
<tr>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
<td><img src="image.jpg" alt=""></td>
</tr>
</table>
<!-- END inner table -->
</td>
<td width="180" valign="top">
<p style="margin-bottom:1000px;"><img src="image.jpg" alt="">rh column</p>
</td>
</tr>
</table>
<!-- END outer table -->
</body>
</html> The center column uses
valign="top" and the contents are independent of the outer table. (Colors, borders and margins added for clarity.) Tables built by WYSIWYG tools are usually badly-done, buggy and over-complicated - I use my editor's code generation tools to build the basic tables and then tweak by hand.
Thanks to all for your help folks, as always