HTML与XHTML区别比较
2014-09-12 16:47
281 查看
以下内容翻译自:http://reference.sitepoint.com/html/html-vs-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
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
相关文章推荐
- 比较HTML、XHTML和XML的区别
- XHTML与HTML之间的区别
- Dhtml,html,xhtml的区别
- Html,sHtml,XHtml区别
- xml xhtml html dhtml的区别
- HTML 和 XHTML的主要区别
- HTML中几个Tag比较有用,平时大家用得比较少,而且是符合W3C XHTML标准的。
- html和xhtml的区别
- HTML和XHTML之间的区别
- HTML,XHTML和XML的区别
- 关于htm和html,shtm与shtml,dhtml,xhtml之间的定义与区别
- HTML与XHTML之间的主要区别
- HTML与XHTML有什么区别?
- xml xhtml html dhtml的区别
- XHTML和HTML的区别
- XHTML与HTML之间的区别
- HTML、SHTML、DHTML、XHTML、XML区别
- HTML 4.01、XHTML 1.0 Strict和Transitional 的区别
- HTML与XHTML的区别
- XHTML和HTML区别