为什么是< div />未处理相同的< div>< / div> [英] Why is <div /> not treated the same as <div></div>

查看:181
本文介绍了为什么是< div />未处理相同的< 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.

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

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