为什么是< br />不同于< br>< / br>在XHTML中? [英] why is <br /> different from <br></br> in XHTML?

查看:89
本文介绍了为什么是< br />不同于< br>< / br>在XHTML中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是HTML页面的完整源代码:

 <!DOCTYPE html PUBLIC -  // W3C // DTD XHTML 1.0 Transitional // EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
< html>
< head>< / head>
< body>
one< br>
two< br />
three< br>< / br>
four
< / body>
< / html>

任何人都可以解释为什么当我在三和四之间出现一个额外的空白行时在IE8或chrome中查看页面?



我认为标准应该让所有浏览器看起来都一样,并且据我所见,该页面符合XHTML过渡标准因为 XHTML规范 HTML兼容性指南指定 br code> 必须应该自动关闭。显然,Chrome和IE8并没有遵循这个规范,并为你打开一个开放的标准,从而创建了第二个换行符。


Here's the complete source of an HTML page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head></head>
<body>
one<br>
two<br />
three<br></br>
four    
</body>
</html>

Can anyone explain why an extra blank line appears between the "three" and the "four" when I view the page in IE8 or chrome?

I thought standards were supposed to make all browsers look the same and as far as I can see this page conforms to the XHTML transitional standard

解决方案

Because the XHTML spec HTML Compatability Guidelines specify that br must should be self closing. Apparently Chrome and IE8 are not follwing the spec and closing the open one for you, thus creating a second line break.

这篇关于为什么是&lt; br /&gt;不同于&lt; br&gt;&lt; / br&gt;在XHTML中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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