View Full Version : input inside form not allowed??
Error: element "input" not allowed here; possible cause is an inline element containing a block-level element
This error I get trough w3's validator on this code:
<pre id=code><font face=courier size=2 id=code>
<form id="frm0">
<input type="text" />
</form>
</font id=code></pre id=code>
Why is that? I don't understand the xhtml strict dtd so.. could anyone tell me why you get error on that code?
Brian Nickel
25.03.2002, 10:07
<pre id=code><font face=courier size=2 id=code><?xml encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test</title>
</head>
<body>
<form id="frm0" action=".">
<fieldset>
<input type="text" />
</fieldset>
</form>
</body>
</html></font id=code></pre id=code>
Containing the inputs in a fieldset appears to be the only way to make it work. The Declairations seemed a bit confusing.
<font face='Courier New'><font color=brown>.Brian
It is best to remain silent and be thought a fool than to open your mouth and remove all doubt.</font id=brown></font id='Courier New'>
Hello, I'm back--
I seem to remember a topic in the past on this exact subject....the problem is that the INPUT element is considered a block element, and under the XHTML DTD, cannot be a direct child element of FORM (which is considered an inline element), so you'll have to wrap your INPUTS in some other block level element. FIELDSET is the intended one, DIV will work just fine.
I prefer using the DIV element to make a logical block-level container, and (if you want to be strict about it) you can then use INPUTs to your heart's content. Like this:
<pre id=code><font face=courier size=2 id=code>
<form id="frm0">
<div id="frm0-container">
<input type="text" />
</div>
</form>
</font id=code></pre id=code>
that way, you validate, you *can* script the div and control all of your form elements (you can do this with a fieldset too), and you're good to go!
Tom Trenka
Brian Nickel
25.03.2002, 12:59
Welcome back, Tom.
<font face='Courier New'><font color=brown>.Brian
It is best to remain silent and be thought a fool than to open your mouth and remove all doubt.</font id=brown></font id='Courier New'>
Thanks Brian. Soon I'll actually be in the swing of things, and hopefully not stick my foot in my mouth anymore than I have too.... ;)
Tom Trenka
Okey now i get it, the DTD files is still a bit confusing for me :)
Thank you
vBulletin® v3.6.7, Copyright ©2000-2008, Jelsoft Enterprises Ltd.