[html5] Validation and <input>

Simon Pieters zcorpan at gmail.com
Sat Dec 1 12:31:18 PST 2007

On Sat, 01 Dec 2007 20:49:05 +0100, john <lists1 at caenim.com> wrote:

> I'm a little confused about the results I am getting from the (X)HTML5
> validator[1]. I have a very basic test page[2] setup like so:
>      <!doctype html>
>      <head><title>input</title></head>
>      <body>
>       <fieldset>
>        <legend>Search this site</legend>
>        <form method="get" action="/search">
>         <input name="Search" type="text" value="search">
>        </form>
>       </fieldset>
>      </body>
> Which looks valid as far as I can tell from the Web Forms and HTML5
> specs, yet the validator says:
>> Error: Bad value “text” for attribute “type” on element “input”.

The error message is correct, but very confusing.

<form> needs block-level children, just like in HTML4. However, unlike  
HTML4, in HTML5 you can put hidden inputs as direct children of <form>.  
Therefore, when the validator finds an <input> as a child of <form>, it  
expects type= to be "hidden".

The way to solve this is obviously not to change the type="" but to put  
the <input> in a block-level element such as <p>, or in this case nest the  
fieldset in the form instead.

Simon Pieters

More information about the Help mailing list