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

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 UTC