今天我遇到了一些代码,在 body 标签开始之前有一个 form 标签。我的意思是,表单标签包含了主体标签。这可能吗?如果是,那么它在哪里有帮助?
<form action="someaction.jsp" method="post">
<body>
...
</body>
</form>
最佳答案
通过查找W3C Recommendations
Form元素描述,它清楚地表明你最好不要那样使用。
您可以在以下位置使用 Form
元素:
Contexts in which this element can be used: Where flow content is expected.
在哪里Flow content被描述为:
Most elements that are used in the body of documents and applications are categorized as flow content.
因此,如果不遵循这些建议,任何 HTML 验证器也会向您报告错误,因为在正文定义中找不到打开结束标签的表单。这是完全有效的,因为:
Tag omission in text/html: Neither tag is omissible.
关于html - 表单标签可以包含主体标签吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30976969/