问题描述
我刚刚通过W3C HTML5验证程序运行了我的网页,并且它完全验证,即使其中的表单没有动作
属性, HTML 4验证器总是抱怨。考虑到HTML5验证器仍然是实验性的事实,即使验证器验证了表单,但验证器验证了该表单,或者将HTML5规范更改为不再需要该属性?
根据 action
不是强制性的:
动作和formaction内容属性,如果指定,必须具有一个值,该值是可能被空格包围的有效非空URL。 / p>
虽然, 4.10.1.3配置表单与服务器通信指出:
所以,我们必须指定服务的URL来处理提交的数据。规范说,如果你想让你的表单与机智沟通h服务器应提供
动作
属性。在我看来,这不是唯一的事实,因为您可以在按钮上指定 action
s。 编辑:我必须承认,我最终无法用是或否回答您的问题...
I've just run a webpage of mine through the W3C HTML5 validator, and it validates completely, even though the form in it doesn't have an action
attribute, which the HTML 4 validator always complains about. Considering the fact that the HTML5 validator is still experimental, is the fact that the form validating despite not having an action
attribute a problem with the validator, or has the HTML5 spec changed to not require that attribute any more?
According to the specification action
is not mandatory:
The action and formaction content attributes, if specified, must have a value that is a valid non-empty URL potentially surrounded by spaces.
Although, section 4.10.1.3 Configuring a form to communicate with a server states that:
You also have to specify the URL of the service that will handle the submitted data, using the action attribute.
So, the specification says that if you want your form to communicate with a server it shall provide the action
attribute. Which, in my opinion, is not the only truth as you can specify action
s on buttons as well.
EDIT: I must admit that I can't finally answer your question with Yes or No...
这篇关于HTML5是否需要表单的操作属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!