<input> within a <form>

I was validating a page today when I got the error:

Error: element “input” not allowed here; possible cause is an inline element containing a block-level element

At first I was confused, but a Google search for that error message quickly pointed me in the right direction. Apparently, <form> must contain a block-level element. And, as <input> is just an inline element, directly enclosing it with a <form> tag wasn’t allowed.

So, I enclosed the tags within <form> by a <div>, and the page now validates as XHTML 1.1. Standards are good :).

2 thoughts on “<input> within a <form>

  1. Cheers for that! I would never have solved that bug in my code without your explanation. Looks like you’re now the authority that Google points to on “element ‘input’ not allowed here” :)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.