为什么是< div />未处理相同的< div>< / div> [英] Why is <div /> not treated the same as <div></div>
问题描述
我只是测试这个,在IE8& Chrome我看到同样的东西,空(样式)的div是不同的渲染方式,你这样做。
编辑
>:感谢您对XHTML Vs HTML的澄清。目前我有这个: < html>
< head>
< meta http-equiv =Content-Languagecontent =en-gb/>
< meta http-equiv =Content-Typecontent =text / html; charset = windows-1252/>
< title> Test< / title>
什么是更好的选择?
在XHTML中提供 Content -type
of application / xhtml + xml
),< div />
确实工作。但是在HTML模式下( text / html
), HTML不是XML,并且无法识别XML空标签语法。
I was just testing this and in both IE8 & Chrome I see the same thing, empty (styled) divs are rendered differently depending which way you do it. It annoys me because the former seems so much neater.
Why?
EDIT: thanks for the clarifications on XHTML Vs HTML. Currently I have this:
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Test</title>
What is a better choice? I'd prefer XHTML as I believe it's a bit nicer.
In XHTML (served with Content-Type
of application/xhtml+xml
), <div />
would indeed work. But in HTML mode (text/html
), then no; HTML is not XML, and XML empty tag syntax is not recognised.
这篇关于为什么是< div />未处理相同的< div>< / div>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!