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.
Yes, you can have a valid input without a form.
I checked the following with the W3C validator and it confirms this is valid.
According to MDN it is possible:
<input>
without a<form>
appears valid, yes (at least for html 4.01, look near the end of 17.2.1):Reference to a more up-to-date specification:
HTML 5.2 - W3C Recommendation (14 December 2017)
Sure, use
to check validity of field dynamically.