在 XHTML 1.1 中:元素“input"不能嵌套在元素“form"中.为什么? [英] In XHTML 1.1: element 'input' cannot be nested within element 'form'. Why?

查看:32
本文介绍了在 XHTML 1.1 中:元素“input"不能嵌套在元素“form"中.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

<input id="_method" name="_method" type="hidden" value=""/></表单>

如果您希望它有效,那么您需要用 div(或 p 等)将其包裹起来,例如:

<div><input id="_method" name="_method" type="hidden" value=""/>

</表单>

这有什么意义?

解决方案

根据 W3C本网站<XHTML 1.1 中的;form> 元素只能包含块级元素和

.

<小时>

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

This below code is forbidden in XHTML 1.1 strict mode:

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

If you want it to be valid then you need to wrap it with a div (or p, etc..) like:

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

How does this make any sense at all?

解决方案

According to the W3C and this site the <form> element in XHTML 1.1 may only contain block level elements and <fieldset>.


As for why ... I believe that the reason that form may only contain block-level elements is because it is not considered an element in itself, but rather a wrapper around other elements. There was some discussion of this in the w3c's mailing lists some years ago that I was able to dig up -- but nothing that actually answered the question.

这篇关于在 XHTML 1.1 中:元素“input"不能嵌套在元素“form"中.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆