Re: Why <FORM> is a block level element?

David Perrell (davidp@earthlink.net)
Thu, 14 Aug 1997 11:10:18 -0700


Message-Id: <199708141816.LAA22081@italy.it.earthlink.net>
From: "David Perrell" <davidp@earthlink.net>
To: <www-html@w3.org>, "Mark Anderson" <marka@cnet.com>
Date: Thu, 14 Aug 1997 11:10:18 -0700
Subject: Re: Why <FORM> is a block level element?

Mark Anderson wrote:
> Adding to this, MSIE seems to put the newline after the <FORM> tag,
while
> Navigator puts it after the </FORM>, causing yet another layout
headache.

I get no layout headaches from FORM. If you enclose all of the block
elements comprising your form inside <FORM>...</FORM>, the results are
the same with IE3.02, N3.01, and N4.01.

Try this markup:

  <P>this is not inside a form</P>

  <FORM>
  <P>this is inside a form</P>
  </FORM>

  <P>this is not inside a form</P>

There is no variation in vertical spacing as a result of the paragraph
being within a FORM element.

The results are somewhat different (but consistent) when using a table.


  <TABLE>
  <TR><TD>this is in table #1</TD></TR>
  </TABLE>

  <TABLE>
  <TR><TD>this is in table #2</TD></TR>
  </TABLE>

  <FORM>
  <TABLE>
  <TR><TD>this is in table #3 in a form</TD></TR>
  </TABLE>
  </FORM>

The default vertical margins on TABLE are less than those on P. The
default vertical margins on FORM are apparently equivalent to those of
P. So in the above example, tables #2 and #3 are separated by the same
vertical margin as paragraphs.

This behavior corresponds to the CSS1 rules regarding the collapsing of
vertical margins. The consecutive vertical margins of FORM and P, and
FORM and TABLE, collapse to the largest of the two. When you enclose
the TABLE in FORM, the effective vertical margin will be the larger,
i.e. that of FORM.

With CSS1, you should be able to give FORM vertical margins of 0 so
that it will have no effect at all on vertical spacing of elements.

As for the newline 'problem', since FORM is a block element there
should always be a newline above and below it. It appears that HTML 4.0
has sensibly disallowed FORM within P, therefore a <FORM> will imply
closure of a preceding paragraph.

David Perrell