Jump to content

saila.com

Online media matters

How do I get rid of the space around forms?

There are two easy ways to do this, the first is a invalid hack, the second uses style sheets. First the hack: embed the form in a table, placing the open and close form between the table elements:
<table>
<form>
<tr>...</tr>
</form>

The second can be done by reducing the forms margins to zero. Most browsers support something like this:
<form style="margin-top: 0; margin-bottom: 0;">

If, however, there elements on either side of the form have margins (like a p), you may need to do this:
<form style="margin-top: -1em; margin-bottom: -1em;">
(you’ll probably have to adjust the margin value to suit your pages).

Netscape 4.x doesn’s support the bottom margin, so you have to reduce the top margin of the element following the form. Given this mark-up:
<p>...</p>
<form>
...
</form>
<p class="second">...</p>
the style rules would look like:
form, p.second { margin-top: -1em; }