Forum Moderators: open

Message Too Old, No Replies

Trouble with tables.

Please help!

         

adni18

9:43 pm on Oct 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey. I need some help here. I have an index page, and I want there to be a big image and then below it, three columns. The ones on left and right about 300px wide, and the one in center all the rest it takes to fill up the width of the table, yet I am having trouble. Someone please help me!

<body style="background:black;color:white">
<table align=center width=571>
<tr><td valign=top>
<img src="tab-top.jpg" width=571 height=400>
</td></tr>
<tr>
<td valign=top>
<table width=530 align=center>
<tr>
<td align=left>
<table cellspacing=0 cellpadding=0>
<tr>
<td colspan=2>
<font style=font-size:9pt color=white face=arial><b>Member Login</b></font>
</td>
</tr>
<tr>
<td>
<font style=font-size:8pt color=white face=arial>Username:</font></td><td><input type=text size=8 style="background:black;border:1px solid white;color:white;height:10pt;font-size:7pt;font-family:arial;position:relative;bottom:2px">
</td>
</tr>
<tr>
<td>
<font style=font-size:8pt color=white face=arial>Password:</font></td><td><input type=password size=8 style="background:black;border:1px solid white;color:white;height:10pt;font-size:7pt;font-family:arial;position:relative;bottom:2px">
</td>
</tr>
</table>
</td>

<td align=center>
hi dude
</td>

<td align=right>
hi
</td>
</tr>
</table>

BlobFisk

9:51 pm on Oct 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi adni18,

Can I suggest that the first thing that you do is run your code through the W3C HTML Validator [validator.w3.org]...

That often highlights a lot of things that you can easily overlook by just scanning your code...

tedster

11:18 pm on Oct 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In addition to validating your table code (an absolute must for debugging), I noticed that your numbers don't seem to add up:

The ones on left and right about 300px wide

That alone sounds like 600px and yet your container table is set for 571px...

...the one in center all the rest it takes to fill up the width of the table

...so there is nothing left over for the center.

I'd suggest starting with the basic table structure, then fill in the width and other attributes, perhap with some "dummy" content", and then finally paste in the real content. You can temporarily add border=1 to the table if you can't figure out why things are going wonky for you.

As I read it, you want a structure like the one below. I think the critical piece of mark-up you are missing is the colspan="3" for the top row of your main table. You don't need to nest tables, as far as I can see.

<table>
<tr>
<td colspan="3">IMAGE</td></tr>

<tr>
<td>LEFT</td>
<td>CENTER</td>
<td>RIGHT</td></tr>

</table>

jo1ene

11:26 pm on Oct 23, 2004 (gmt 0)

10+ Year Member



You can temporarily add border=1 to the table if you can't figure out why things are going wonky for you.

Good advise.

Your strategy sounds like a good application for perecentage widths such as left 25%, middle 50%, right 25%. As mentioned before, you're not going to get the full effect of a table without dummy content.

encyclo

11:27 pm on Oct 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The ones on left and right about 300px wide, and the one in center all the rest it takes to fill up the width of the table, yet I am having trouble.

You defined your table as being 571 pixels wide, so if you want the left and right columns as 300 pixels each, you've got a problem! In your example, your left column nested table is marked as 530 pixels, leaving you 41 pixels for the other two.

I would fix the layout first, decide what you need, then add in the content to each section. Start with a really basic layout such as this:

<table cellpadding="0" cellspacing="0" border="1" width="571">
<tr><td colspan="3">Image here<td></tr>
<tr>
<td width="100">Left column</td>
<td width="371">Middle column</td>
<td width="100">Right column</td>
</tr>
</table>

and then adjust the widths to suit. After that, feed in the content and change

border="1"
to
border="0"
.

beaten to it!

adni18

12:11 am on Oct 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But even this results in the first column being much wider than the others:

<body style="background:black;color:white">
<table align=center>
<tr>

<td valign=top colspan=3>
<img src="tab-top.jpg" width=571 height=400>
</td>

</tr>

<tr>

<td bgcolor=green>M</td>

<td bgcolor=lime valign=top align=center>

</td>

<td bgcolor=blue valign=top align=right>

</td>

</tr>

</table>

vkaryl

12:26 am on Oct 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One REALLY good way to figure out what's going on with your code is to look at a site structured the way you have in mind for your site. You can view the source and see what's different there from what you're using.

And you absolutely need to use borders and different colors while you get it whacked out....

adni18

2:36 pm on Oct 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Aha! My partner figured out the problem. I had put the table INSIDE of the <TD> tag, which, (in IE) resulted in a misinterperetation.

adni18

1:11 pm on Oct 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you, everyone!