IE9错误(可选)< / p>关 [英] IE9 bug with optional </p> close

查看:103
本文介绍了IE9错误(可选)< / p>关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在IE9中的代码,意外的是,由于在标题后缺少< / p>



现场演示

 < style> 
#MyForm div {
width:200px;
height:30px;
float:left;
}
< / style>
< div>
< p>< b>登录< / b>
< form id =MyFormaction =test.html>
< div>
< label>我的电子邮件< / label>
< input />
< / div>
< div>
< label>我的密码< / label>
< input type =password>
< / div>
< / form>
< / div>

这是一个错误还是只是我?



更新



根据W3C,块级别元素在p标记内无效

 < P> 
< DIV> ...< / DIV>
< / P>

但可以关闭< p> 标记因此,

 < p>内容块1 
< p>内容块2
< p>内容块3
< form> .....< / form>

这看起来有效。如果第一个示例中没有显式关闭,块元素应自动关闭< p>

解决方案

这似乎是一个IE9的错误。



做了一些更多的测试(并添加一些< span> ; c> )到IE9标准模式看起来像IE9无法识别< form> 不能作为< p> ,但不承认不允许< div>



p元素节点的后代直到它遇到第一< div> ,此时它终止< form> 之后插入表单主体的其余部分 p>

遇到< / form> 时,将其视为非打开元素的结束标记, 。


I tried this code in IE9, unexpectedly it got screwed because of a missing </p> after heading.

live demo

<style>
#MyForm div {
    width: 200px;
    height: 30px;
    float: left;
}
</style>
<div>
    <p><b>Login</b>
    <form id="MyForm" action="test.html">
        <div>
            <label>My Email</label>
            <input />
        </div>
        <div>
            <label>My Password</label>
            <input type="password">
        </div>
    </form>
</div>

It is a bug or just me?

Update

A block level element is invalid inside a "p" tag as per W3C

<P>
    <DIV>...</DIV>
</P>

But it's optional to close <p> tag so,

<p>content block 1
<p>content block 2
<p>content block 3
<form> ..... </form>

This appears valid. A block element should automatically close <p> if it's not explicitly closed as in first example.

解决方案

This does appear to be an IE9 bug.

After doing some more testing (and adding some <span>s into the form), in IE9 Standards Mode it looks like IE9 fails to recognise that a <form> is not allowed as a descendent of a <p> but does recognise that a <div> is also not allowed.

Consequently it inserts elements as descendants of the p element node until it encounters the first <div>, at which point it terminates the <form> and the <p> and then inserts the rest of the form body after the form.

When it encounters </form> it treats it as an end tag for a non-open element and ignores it.

这篇关于IE9错误(可选)&lt; / p&gt;关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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