Web Hosting Talk







View Full Version : Why is this HTML doing weird positioning?


Mechphisto
02-18-2010, 06:17 PM
Hi all,
I've got a bit of HTML that's doing weird things.
See the table down in there? (I know I know, tables. If there's a better way of laying this info out in this appearance without using a table...and a bunch of exactly placed div's, I'm all ears.)
For some reason all the content below the table wants to appear on the right side as it the table is a left-aligned image!
Despite the fact there's <p> in between as well as the table and the following content are placed in their own div tags.

If I force the table to 100% (odd it's not defaulting to 100% anyway) then there's no problem...but I don't want a 100% table.

If I remove all the div's no change.
If I use Firebird's Firebug to turn off ALL CSS styles, still no change.
And there's no HTML being echoed in the PHP tags you're seeing in there.

What in the world is happening? Any ideas? Especially how to stop it?

Thanks for any feedback,
Liam

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<LINK REL=StyleSheet HREF="../includes/styles.css" TYPE="text/css" MEDIA=screen>
</head>

<body>
<div id="mainresults" align="left">
<p class="main_bold">Is this the information you want to submit?</p>
<p class="main_bold">&nbsp;</p>
<p class="main_bold_med">LPS Planning Program:</p>
<p class="main_bold_med"><span class="mainhead_med" style="padding-left:20px"><?=$chk_who_DISP?></span></p>
<p class="main_bold_med"><br />Program Title:</p>
<p class="main_bold_med"><span class="mainhead_med" style="padding-left:20px"><?=$txt_programtitle_DISP?></span></p>
<p class="main_bold_med"><br />Age Level:</p>
<div class="mainhead_med" style="padding-left:20px"><?=$chk_age_DISP?></div>
</div>

<!-- ~~~~~~~~~~~~~~~~~~ -->
<!-- BEGIN DYNAMIC AREA -->

<p>&nbsp;</p>
<div id="dynamicresults" align="left">
<table align="left" border="0" cellpadding="2" cellspacing="0" width="400px">
<tr>
<td class="main_bold_med">Date:</td><td colspan="3" class="mainhead_med"><?=$date_date_DISP?></td>
</tr>
<tr>
<td class="main_bold_med">Time:</td><td colspan="3" class="mainhead_med"><?=$date_time_DISP?></td>
</tr>
<tr>
<td class="main_bold_med">Location:</td><td colspan="3" class="mainhead_med"><?=$txt_location_DISP?></td>
</tr>
<tr>
<td class="main_bold_med">Location Code:</td><td colspan="3" class="mainhead_med"><?=$txt_loc_code_DISP?></td>
</tr>
<tr>
<td class="main_bold_med">Registration Deadline:</td><td colspan="3" class="mainhead_med"><?=$deadline_DISP?></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td><td class="main_bold_med">Min/Max:</td><td class="mainhead_med"><?=$txt_minmax_DISP?></td>
</tr>
<tr>
<td class="main_bold_med">Girl Cost:</td><td class="mainhead_med"><?=$txt_cost_girl_DISP?></td><td class="main_bold_med">Adult Cost:</td><td class="mainhead_med"><?=$txt_cost_adult_DISP?></td>
</tr>
</table>
</div>
<p>&nbsp;</p>


<!-- END DYNAMIC AREA -->
<!-- ~~~~~~~~~~~~~~~~ -->

<div id="mainresults2" align="left">
<p class="main_bold_med"><br />Description:</p>
<div id="mainresults2b" class="mainhead_med" style="padding-left:20px"><?=$txt_description_DISP?></div>
<p><span class="main_bold_med"><br />Leadership Key(s):</span>
<div id="leadership" style="padding-left:20px">
<p><strong>Discover </strong></p>
<?=$chk_discover_DISP?>
<p><strong>Connect </strong></p>
<?=$chk_connect_DISP?>
<p><strong>Take Action </strong></p>
<?=$chk_action_DISP?>
</div>
</p>
</div>
</body>
</html>

PogiWeb
02-18-2010, 06:21 PM
Can you post a screenshot of the troubled area and your css.

Mechphisto
02-18-2010, 06:28 PM
Absolutely...
attached.
Thanks!

Oh, I'm using Firebug to outline the table and cells. The "Description", "Leadership Keys", and "Discover" should be appearing below the table.

Bingen
02-18-2010, 08:33 PM
Maybe you're missing some tags.
I do tables this way:

<table summary="XY" id="" cellspacing="0">
<caption>XY</caption>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3">Table foot</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>

Good luck.

Mechphisto
02-19-2010, 11:48 AM
Huh, I learned HTML circa '95, so I never got used to using thead, tfoot, tbody... guess I haven't kept myself up to date very well.
In any case, I added all those and it still is trying to place the following content along the right side of the table.
Thanks for the suggestion though. :)

Mechphisto
02-19-2010, 02:31 PM
Well, until a better, proper fix can be found, I've just set the table width at 100% and then used set pixel widths for the first 3 of 4 cells, leaving the last TD to take up the rest of the 100%.
Not elegant, but at least it stops the following content from trying to put itself to the right of the table.

Mechphisto
02-19-2010, 05:25 PM
Dang it! That didn't actually fix it.
It's fine in Firefox, but in IE7 and 8 there's a bunch of content below the table that is STILL being placed at the far right of the table at 100% width. Have to scroll right to see it.
So, there's still something really hinky going on.
I'm at a loss.
Here's the fill code:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<STYLE TYPE="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
color: #000000;
font-size: 12px;
font-weight:normal;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.mainhead_med {
color: #000000;
font-size: 12px;
font-weight:bolder;
font-family: Geneva, Arial, Helvetica, sans-serif;
margin: 15px 0 0;
}
.main_bold {
color: #3C757F;
font-size: 14px;
font-weight:bolder;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.main_bold_med {
color: #3C757F;
font-size: 12px;
font-weight:bold;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
</STYLE>
</head>

<body>
<div id="mainresults" align="left">
<p class="main_bold">Is this the information you want to submit?</p>
<p class="main_bold">&nbsp;</p>
<p class="main_bold_med">LPS Planning Program:</p>
<p class="main_bold_med"><span class="mainhead_med" style="padding-left:20px">YOU DID NOT SELECT ANY LEADERSHIP PLANNING SPECIALISTS</span></p>
<p class="main_bold_med"><br />Program Title:</p>
<p class="main_bold_med"><span class="mainhead_med" style="padding-left:20px"></span></p>
<p class="main_bold_med"><br />Age Level:</p>
<div class="mainhead_med" style="padding-left:20px">YOU DID NOT SELECT ANY AGE LEVELS</div>
</div>

<!-- ~~~~~~~~~~~~~~~~~~ -->
<!-- BEGIN DYNAMIC AREA -->

<p>&nbsp;</p>
<div id="dynamicresults" align="left">
<table align="left" border="0" cellpadding="2" cellspacing="0" width="100%">
<tbody>
<tr>
<td class="main_bold_med" width="145px" align="right">Date:</td><td colspan="3" class="mainhead_med">Friday, February&nbsp;19, 2010</td>
</tr>
<tr>
<td class="main_bold_med" align="right">Time:</td><td colspan="3" class="mainhead_med">X:00&nbsp;PM to X:00&nbsp;PM</td>
</tr>
<tr>
<td class="main_bold_med" align="right">Location:</td><td colspan="3" class="mainhead_med">Girl Scout Service Center, Joplin</td>
</tr>
<tr>
<td class="main_bold_med" align="right">Location Code:</td><td colspan="3" class="mainhead_med">PRG_110</td>
</tr>
<tr>
<td class="main_bold_med" align="right">Registration Deadline:</td><td colspan="3" class="mainhead_med">February&nbsp;19, 2010</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td><td class="main_bold_med" align="right">Min/Max:</td><td class="mainhead_med">100/300</td>
</tr>
<tr>
<td class="main_bold_med" align="right">Girl Cost:</td><td width="90px" class="mainhead_med">100,000</td><td width="95px" class="main_bold_med" align="right">Adult Cost:</td><td class="mainhead_med">Free to observe</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>


<!-- END DYNAMIC AREA -->
<!-- ~~~~~~~~~~~~~~~~ -->

<div id="mainresults2" align="left"></p>
<p class="main_bold_med"><br />Description:</p>
<div id="mainresults2b" class="mainhead_med" style="padding-left:20px"></div>
<span class="main_bold_med"><br />Leadership Keys:</span>
<div id="leadership" style="padding-left:20px">
<p><strong>Discover </strong></p>
<p><strong>Connect </strong></p>
<p><strong>Take Action </strong></p>
</div>
</div>
</body>
</html>

DDHS Bob
02-19-2010, 05:51 PM
Remove align="left" from everything - it's not needed. Final code with problem solved will look like this:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<STYLE TYPE="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
color: #000000;
font-size: 12px;
font-weight:normal;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.mainhead_med {
color: #000000;
font-size: 12px;
font-weight:bolder;
font-family: Geneva, Arial, Helvetica, sans-serif;
margin: 15px 0 0;
}
.main_bold {
color: #3C757F;
font-size: 14px;
font-weight:bolder;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.main_bold_med {
color: #3C757F;
font-size: 12px;
font-weight:bold;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
</STYLE>
</head>

<body>
<div id="mainresults" align="left">
<p class="main_bold">Is this the information you want to submit?</p>
<p class="main_bold">&nbsp;</p>
<p class="main_bold_med">LPS Planning Program:</p>
<p class="main_bold_med"><span class="mainhead_med" style="padding-left:20px">YOU DID NOT SELECT ANY LEADERSHIP PLANNING SPECIALISTS</span></p>
<p class="main_bold_med"><br />Program Title:</p>
<p class="main_bold_med"><span class="mainhead_med" style="padding-left:20px"></span></p>
<p class="main_bold_med"><br />Age Level:</p>
<div class="mainhead_med" style="padding-left:20px">YOU DID NOT SELECT ANY AGE LEVELS</div>
</div>

<!-- ~~~~~~~~~~~~~~~~~~ -->
<!-- BEGIN DYNAMIC AREA -->

<p>&nbsp;</p>
<div id="dynamicresults">
<table border="0" cellpadding="2" cellspacing="0">
<tbody>
<tr>
<td class="main_bold_med" width="145px" align="right">Date:</td><td colspan="3" class="mainhead_med">Friday, February&nbsp;19, 2010</td>
</tr>
<tr>
<td class="main_bold_med" align="right">Time:</td><td colspan="3" class="mainhead_med">X:00&nbsp;PM to X:00&nbsp;PM</td>
</tr>
<tr>
<td class="main_bold_med" align="right">Location:</td><td colspan="3" class="mainhead_med">Girl Scout Service Center, Joplin</td>
</tr>
<tr>
<td class="main_bold_med" align="right">Location Code:</td><td colspan="3" class="mainhead_med">PRG_110</td>
</tr>
<tr>
<td class="main_bold_med" align="right">Registration Deadline:</td><td colspan="3" class="mainhead_med">February&nbsp;19, 2010</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td><td class="main_bold_med" align="right">Min/Max:</td><td class="mainhead_med">100/300</td>
</tr>
<tr>
<td class="main_bold_med" align="right">Girl Cost:</td><td width="90px" class="mainhead_med">100,000</td><td width="95px" class="main_bold_med" align="right">Adult Cost:</td><td class="mainhead_med">Free to observe</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>


<!-- END DYNAMIC AREA -->
<!-- ~~~~~~~~~~~~~~~~ -->

<div id="mainresults2"></p>
<p class="main_bold_med"><br />Description:</p>
<div id="mainresults2b" class="mainhead_med" style="padding-left:20px"></div>
<span class="main_bold_med"><br />Leadership Keys:</span>
<div id="leadership" style="padding-left:20px">
<p><strong>Discover </strong></p>
<p><strong>Connect </strong></p>
<p><strong>Take Action </strong></p>
</div>
</div>
</body>
</html>

Mechphisto
02-19-2010, 08:43 PM
I'm out about on my iPhone so I can't try it, but that sounds right. I even hinted at it talking about it behaving like a left-aligned image! Gah!
I didn't think that worked like that on tables.
*hangs head* I can't believe all my frustration and I should have caught that.
Thanks for the reply and suggestion!

Mechphisto
02-22-2010, 01:10 PM
By the way, yeah, that did it. Thanks for the clue-by-four to the head! :)

SiskiyouWebDesign
02-22-2010, 03:11 PM
The chances are pretty good that the coding causing your issue is in your CSS style for "dynamicresults" is in conflict with your "align=right" HTML withing your TD tags. The browsers can be non-forgiving on their rendering of CSS, I would use pure CSS to position and align and forget the HTML. You may have to look at it from an "inheritance" stand-point with your layout. In other words, start at the Parent Tag <body> running through <div>, <table>, <tr>, <td> making sure your alignment is not in each spot and if it is, that its effect on the data in the <table>. I would use CSS and get away from the Tables personally.