HTML与XHTML区别比较


1、html大小写不敏感,XHTML敏感,只能用小写标签

2、html标签不一定要求闭合,但是XHTML标签必须闭合
     在html中,下面有效: <p>This is my first paragraph.<p>This is my second paragraph.<p>And here’s the last one. .
     但在Xhtml中,必须改为: <p>This is my first paragraph.</p><p>This is my second paragraph.</p><p>And here’s the last one.</p>

3、html甚至允许某些标签(html,head,body,tbody)不需要起始标签,但不建议这么做

4、XHTML要求空元素如img必须加上终止符“/”:<elementname attribute="attributevalue"/>,如果是“ application/xhtml+xml”MIME类          型,空元素可以使用start和end tag。如img标签可以写成: <img> </img>

5、XHTML要求所有属性的值必须使用引号(单引号和双引号都可以)括起来,如class=“gallery”,不能写成class=gallery。

     而在HTML中,属性值可以没有引号


6、XHTML中必须要有<html><head><body>元素,html中可以没有。


7、XHTML可以使用类似<p/>来直接表示元素没有内容,html则不能。


8、XHTML中所有的属性必须写成:属性=“属性值”的形式,而html中允许某些boolean类型的属性只写属性名,不需要写属性值。

     如html中表示选中的input元素可以这样写:<input type="checkbox" name="chkNewsletter" checked>;

     而在xhtml中必须写成:<input type="checkbox" name="chkNewsletter" checked="checked">.


9、在XHTML中,设置元素内容的语言要用xml:lang属性,在html中用lang属性。


10、在XHTML中,需要在HTTP头部设置正确的MIME类型:"application/xhtml+xml" (this is the best option), "application/xml" (acceptable),           or "text/xml" (which isn’t recommended)。


11、XHTML中,text encoding should be set within the XML declaration, not in the HTTP headers (although doing the latter is still allowed).

      元素的属性之间的空格不管多少,只要至少有一个就行。


12、XHTML在处理script和stylesheet也有很大差异:document.write() and document.writeln() do not work in XHTML



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值