tags:

views:

84

answers:

2

Is it valid to have <input> without it being in a <form>?

Have a process for marking up some fields in pages and just found a page with input fields that where not being marked up as I expected.
It's taken me a while but worked out that the process of getting the form elements then getting the fields is what caused these to be missed because there is no form.

+1  A: 

Yes, you can have a valid input without a form.

kekekela
I'm assuming I'm getting downvoted for answering correctly first, makes sense.
kekekela
Well, you could have added some evidence behind the 'yes'. Or a clarification of which versions of HTML this is true for. Still, I wouldn't have downmodded you.
Adriano Varoli Piazza
Agree to disagree I guess. If I can provide a correct answer during a break I don't mind doing so. I really can't be assed to copy/paste from w3 when the op could've just as easily gone and looked it up there himself, though. If you want to vote up the wordier, later answer that's cool and apparently becoming the norm around here as people game points, but downvoting mine is just lame in my opinion.
kekekela
+4  A: 

<input> without a <form> appears valid, yes (at least for html 4.01, look near the end of 17.2.1):

The elements used to create controls generally appear inside a FORM element, but may also appear outside of a FORM element declaration when they are used to build user interfaces. This is discussed in the section on intrinsic events. Note that controls outside a form cannot be successful controls.

ChristopheD
I have just created an `<input>` tag outside of a form in Visual Studio 2010 and it had no problem with it. So I agree it is odd, even pointless, but not illegal.
Philip Smith
Ta, was having trouble finding that info
Greg Domjan