W3C home > Mailing lists > Public > www-validator@w3.org > December 2005

Re: Input element in a form, what am I doing wrong?

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Tue, 13 Dec 2005 20:46:47 +1100
Message-ID: <439E9887.3020404@lachy.id.au>
To: Brian Williams <BWilliams@brianwilliams.com>
CC: www-validator <www-validator@w3.org>

Brian Williams wrote:
> I do not understand what this message means:
> 
> Error Line 13 column 65: document type does not allow element "input" 
> here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", 
> "pre", "address", "fieldset", "ins", "del" start-tag.
> ...
> <!DOCTYPE html
>      PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> ...
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

In XHTML documents, this particular meta element is completely useless
and in HTML, it is an inferior substitute for real HTTP headers.  Do
some searching for XHTML MIME types, HTTP headers and .htaccess files to
learn how to do that properly.

> <form method="get" action="http://www.brianwilliams.com/xhtml.html">
> <input type="hidden" name="action" id="action" value="gotohome" />
> <input type="submit" value="Submit" />
> </form>

With a Strict DOCTYPE (either HTML 4.01 Strict or XHTML 1.0 Strict), you 
cannot place input elements directly inside a form element.  You need to 
use an appropriate block level container element, such as <p>, 
<fieldset>, etc.

<form method="get" action="http://www.brianwilliams.com/xhtml.html">
<p>
   <input type="hidden" name="action" id="action" value="gotohome" />
   <input type="submit" value="Submit" />
</p>
</form>

-- 
Lachlan Hunt
http://lachy.id.au/
Received on Tuesday, 13 December 2005 09:47:10 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:20 GMT