为什么浏览器发疯,当我写的东西像&LT; DIV /&GT ;? [英] Why does the browser go crazy when I write things like <div/>?
问题描述
我的意思是,不是&LT; DIV /&GT;
和&LT; DIV&GT;&LT; / DIV&GT;
应该是的究竟的同样的事情?
通过浏览器我的意思是最新的Firefox和Internet Explorer。并发疯我的意思是忽略风格包含标签&LT; DIV /方式&gt;
不是
&LT; DIV /&GT;
和&LT; DIV&GT /;
应该DIV&GT;&LT是完全一样的东西?
块引用>只有在XML。你提供你的网页为XML(
是application / xhtml + XML
)?如果是这样,你可以使用,但你会牺牲IE9之前的IE版本的兼容性。如果像大多数人一样,你所服务的XHTML页面
的text / html
,你必须通过的兼容性指南,其中一个是你必须的只有的使用自结束标记为有一个<$ C $元素C>空缺内容模型,即得。的那些凡在HTML你使用一个标签,没有密切的标签(&LT; IMG&GT;
等)。否则,你刚刚写什么非XML解析器HTML将看到没有结束标记,这很可能会乱页面的嵌套了一个起始标签。
&LT; DIV /方式&gt;
将会把整个页面的其余部分的该div内I mean, aren't
<div/>
and<div></div>
supposed to be exactly the same thing?By browser I mean the latest Firefox and Internet Explorer. And by go crazy I mean ignore styles of tags that contain the
<div/>
.解决方案aren't
<div/>
and<div></div>
supposed to be exactly the same thing?Only in XML. Are you serving your web page as XML (
application/xhtml+xml
)? If so you can use either, but you'd be sacrificing compatibility with IE versions before IE9.If like most people you are serving an XHTML page as
text/html
, you must abide by the compatibility guidelines, one of which is that you must only use self-closing tags for elements that have anEMPTY
content model, ie. the ones where in HTML you'd use a single tag with no close-tag (<img>
et al).Otherwise, you've just written what non-XML HTML parsers will see as a start-tag with no end-tag, which is likely to mess the page's nesting up.
<div/>
will put the whole of the rest of the page inside that div.这篇关于为什么浏览器发疯,当我写的东西像&LT; DIV /&GT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!