Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form tags around a table causing alignment error 1

Status
Not open for further replies.

miraclemaker

Programmer
Oct 16, 2002
127
GB
When I use the code

Code:
...
<td><form method=&quot;post&quot; name=&quot;form20&quot; action=&quot;/one/two.php&quot;><table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;183&quot;>
	<tr>
	  <td>
	  ...form elements...
	  </td>
	</tr>
</table></form></td>
...

(which is itself in another table, code massively cropped down for clarity) I get a large space *after* the form finishes and still within the table cell that contains the form. The picture here:
sample.gif

will help you understand. (the gap is after the 'product status' pulldown.

I have found if I move the form tags so that they are immediately inside the <table> tags (rather than outside) like this:

Code:
<table>
  <form>
    <tr>
      <td>
      ...form elements...
      </td>
    </tr>
  </form>
</table>

the gap disappears and the form works perfectly. However this fails to vailidate through the w3c HTML validator becuase of course this is no longer valid HTML.

Anybody got any ideas how I can fix this?

Thanks.
 
you can use this principle :

<form>
<table>
<!-- content -->
</table>
</form>

It should help with your problem. If this doesn't help I believe there may also be a solution that CSS could provide. Let me know if this doesn't work and i'll see if I can dig up a CSS solution. Gary Haran
 
FANTASTIC!

I used (to save adding to my style sheet that effects the whole site)
<form method=&quot;post&quot; name=&quot;form20&quot; action=&quot;/one/two.php&quot; style=&quot;margin:0px&quot;>

and it fixes the problem perfectly. Thank you so much.
 
Cian is right about the &quot;margins&quot;

But his way set's all the margin to zero.
Maybe it's better to set only the top- or bottom-margin.

set top and bottom separately
<form name=&quot;SlideShow&quot; style=&quot;margin-top:2px; margin-bottom: 3px&quot;>

Of course you can set also the margin-left and margin-right but I doubt if you need that.

This example is inline-CSS but you can also put it in your CSS-file

Hope this helps,
Erik <-- My sport: Boomerang throwing !!
!! Many Happy Returns !! -->
 
I don't understand why they default the form to having a margin! it isn't a visual tag but a frikking technical tag!

I'm glad it can be fixed via CSS! :) Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top