"Input Type" Error


I added a search form to my site however the validator keeps creating an error based on “input” typle at the start of the 2 inputs. The problem is I thought input areas were labelled.

Can anyone advise please what I should be using instead of input?

<form action="/products/searchresults" method="post">
<input type="text" name="keywords" size="20" class="homepagesearch" />
<input type="image"  value="Submit" src="/images/search.png" alt="Search" name="image" />

What are you trying to validate it as?
Your example validates perfectly as as XHTML 1.0 Transitional.

Hi yes it is XHTML 1.0

I just have it inside a standard DIV. The form works fine, it just creates an HTML error.

Putting it inside a div makes no difference, it still validates.
See here (if you scroll down the page, you can see the source).


I am using XHTML 1 Strict. But it should still work. Is their anything else it could be down to?

The FORM element really should have a FIELDSET and LEGEND or at the bare minimum a block-level element. Remember INPUT are inline elements. The FIELDSET is usually supposed to come directly after the start FORM tag.

Indeed, it doesn’t validate as XHTML strict.
The two lines containing the <input> elements throw the following error:

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"

What this means is that you can’t have the input element as a direct child of the form. They must be contained within one of “p”, “h1”, “h2”, “h3”, “h4”, “h5”, “h6”, “div”, “pre”, “address”, “fieldset”, “ins”, “del”.
As xhtmlcoder says you should probably put them in <fieldset> and <legend> tags.

It’s also a good idea to include a label, even if you hide it for sighted users.