View Full Version : W3 Validator is crazy?!

Feb 11th, 2010, 01:07 PM
I get the error:
Line 31, Column 87: 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

…search" id="search" value="search" />

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

line 31:

<input type="text" name="search" id="search" value="search" />

Can someone please help and tell me why its erroring?

Puffin the Erb
Feb 11th, 2010, 01:12 PM
Sounds like you are using strict xhtml and so need to place your form inside a block element as listed by the validator.
Another possibility is you have not closed a tag somewhere earlier in the markup.

Feb 11th, 2010, 01:17 PM
In semantic terms you should use the following structure:

<legend>To Name Your Fieldset</legend>
<label>Your your input</label>
<input />

The fieldset is a block-level element that wraps everything contained in the form as the form itself cannot directly contain an inline element, such as an input

Major Payne
Feb 13th, 2010, 08:16 AM
Without a lot of re-coding, just put the following in a set of "p" or "div" tags:
<input type="text" name="search" id="search" value="search" />
When using the XHTML 1.0 doctype, you're going to get flagged for these unless you take care of them ahead of time.

<p><input type="text" name="search" id="search" value="search" /></p>or
<div><input type="text" name="search" id="search" value="search" /></div>

Those are quick and easy solutions.

Feb 13th, 2010, 12:05 PM
Sorry, I have to object a little: Paragraphs are plain wrong in this context in terms of semantics. A form control ain’t no paragraph of text so a div is to be preferred.