In proper HTML, must an <input> be in a <form>?

江枫思渺然 提交于 2019-12-06 17:30:50

问题


I need a few input elements, but their values won't be submitted anywhere - they're just going to be manipulated by some client-side JavaScript. Do I have to place them in a <form> to have legit HTML, or can they just be free-standing?


回答1:


For additional information, in xhtml strict you have to place in one of these elements: "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "address", "fieldset"




回答2:


No. You only need a form if you're submitting to a server.



来源:https://stackoverflow.com/questions/2862050/in-proper-html-must-an-input-be-in-a-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!