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

问题描述

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

      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 HTML Compatability Guidelines specify that br 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中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 13:15