有<input>而不是<form>是有效的吗?
有一个在页面中标记一些字段的过程,只是发现了一个输入字段的页面,那里没有被标记为我所期望的。 这花了我一段时间,但得出的过程中,得到的形式元素,然后得到的领域是什么导致这些错过,因为没有形式。
有<input>而不是<form>是有效的吗?
有一个在页面中标记一些字段的过程,只是发现了一个输入字段的页面,那里没有被标记为我所期望的。 这花了我一段时间,但得出的过程中,得到的形式元素,然后得到的领域是什么导致这些错过,因为没有形式。
当前回答
in my point of view , we can use input outside the form and even send data to the server without put the input in the form ,but for SEO and website readability(for visually impaired people)(just the same reason for the some semantic content tags in HTML5 , like section ,footer, header something like that ), we have to use input in the form tag.It is important that we ensure the code we use is available to all people including the visually impaired people because it is not just about websites, it is about providing access to information for everyone.
其他回答
是的,您可以在没有表单的情况下获得有效的输入。
<input>没有<form>是有效的,是的(至少对于HTML 4.01,看17.2.1的结尾):
用于创建控件的元素 通常出现在表单中 元素,但也可能出现在外部 的FORM元素声明 它们被用来建立用户 接口。这在 内在事件部分。请注意, 窗体之外的控件则不能 成功的控制。
I know this question is quite old, however, I have successfully built many complex data entry pages without form tags. Although it isn't considered "standard" by many, it is NOT inappropriate to use inputs without a <form>. My projects were instances where I needed complete control over how the page behaved and the default form behavior was getting in the way. Was able to perform page and field level validation ( using JS ) and "submitted" the data with Ajax calls etc...in fact, this is my preferred way these days.
需要大量的JS,但它不是那么困难,可以很容易地完成可重用的代码。
还有其他实例,我定义不使用表单输入,如登录页面。
希望这篇感言能帮助到一些人。
我用W3C验证器检查了以下内容,并确认这是有效的。
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<input type='text' />
</body>
</html>
in my point of view , we can use input outside the form and even send data to the server without put the input in the form ,but for SEO and website readability(for visually impaired people)(just the same reason for the some semantic content tags in HTML5 , like section ,footer, header something like that ), we have to use input in the form tag.It is important that we ensure the code we use is available to all people including the visually impaired people because it is not just about websites, it is about providing access to information for everyone.