[html5] Validation and <input>

john lists1 at caenim.com
Sun Dec 2 11:22:50 PST 2007


On 2007/12/01, at 13:31, Simon Pieters wrote:

> 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.
>
> HTH,
> -- 
> Simon Pieters

Thanks guys. After reading your emails I went back and re-read the  
specs and now (I think) it makes perfect sense. It at least makes  
enough sense to get my form validating.

thanks again,
john


More information about the Help mailing list