[XHTML Tutorial] 走向XHTML标准 (3)(Differences Between XHTML And HTML)[2]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 lovewangshu 的 blog

标记的名字必须用小写字母
this is because xhtml documents are xml applications. xml is case-sensitive. tags like <br> and <br> are interpreted as different tags.
这是因为xhtml文档是xml的应用程序,xml是大小写敏感的,像<br>和<br>是会被认为为两种不共的标记的。
this is wrong:
错误的:
<body>
<p>this is a paragraph</p>
</body>

this is correct:
正确的

<body>
<p>this is a paragraph</p>
</body>

all xhtml elements must be closed
所有的xhtml标记都必须有关闭符
non-empty elements must have an end tag.
非空的标记必须有一个关闭符。
this is wrong:
这是错误的:

<p>this is a paragraph
<p>this is another paragraph

this is correct:
这才是正确的

<p>this is a paragraph</p>
<p>this is another paragraph</p>

empty elements must also be closed
空标记也必须有关闭符
empty elements must either have an end tag or the start tag must end with />.
空标记必须有关闭符或以开始符加上 />来结束
this is wrong:
错误的代码

this is a break<br>
here comes a horizontal rule:<hr>
here's an image <img src="happy.gif" alt="happy face">

this is correct:
正确的:

this is a break<br />
here comes a horizontal rule:<hr />
here's an image <img src="happy.gif" alt="happy face
" />

important compatibility note:
关于兼容性的重要的注释:
to make your xhtml compatible with today's browsers, you should add an extra space before the "/" symbol like this: <br  />, and this: <hr  />.
为了使你的xhtml能够兼容现在的浏览器,你必须在/符号之前加一个特殊的空格,就像这样:<br  /><hr  />

本文关键:[XHTML Tutorial] 走向XHTML标准 (3)(Differences Between XHTML And HTML)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top