gpt4 book ai didi

xhtml - 在 XHTML 1.1 : element 'input' cannot be nested within element 'form' . 为什么?

转载 作者:行者123 更新时间:2023-12-04 01:02:49 25 4
gpt4 key购买 nike

下面的代码在 XHTML 1.1 严格模式下是禁止的:

<form method="post" action="index">
<input id="_method" name="_method" type="hidden" value="" />
</form>

如果您希望它有效,那么您需要用 div(或 p 等)将其包装起来,例如:
<form method="post" action="index">
<div>
<input id="_method" name="_method" type="hidden" value="" />
</div>
</form>

这有什么意义呢?

最佳答案

根据W3Cthis site <form> XHTML 1.1 中的元素可能只包含块级元素和 <fieldset> .

至于为什么...我相信原因是form可能只包含块级元素是因为它本身不被视为元素,而是其他元素的包装器。有 some discussion几年前在 w3c 的邮件列表中,我能够挖掘到这一点 - 但实际上没有回答这个问题。

关于xhtml - 在 XHTML 1.1 : element 'input' cannot be nested within element 'form' . 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2158303/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com