所有的 XHTML 元素一定要关闭
不能有没有关闭的空的元素存在我们的代码中,其实对于这点我们是比较好结束的,有开始就应该有结束吗?例如错误代码: <p>This is a paragraph
<p>This is another paragraph
<p>This is a paragraph</p>
<p>This is another paragraph</p>
This is a break<br>
Here comes a horizontal rule:<hr>
Here's an image <img src="happy.gif" alt="Happy face">
This is a break<br />
Here comes a horizontal rule:<hr />
Here's an image <img src="happy.gif" alt="Happy face" />
<table WIDTH="100%">
正确的代码:<table width="100%">
属性值必须要被引用。如:<table width=100%>
正确的代码:<table width="100%">
属性的缩写被禁止。如: <dl compact>
<input checked>
<input readonly>
<input disabled>
<option selected>
<frame noresize>
<dl compact="compact">
<input checked="checked" />
<input readonly="readonly" />
<input disabled="disabled" />
<option selected="selected" />
<frame noresize="noresize" />
HTML XHTML
compact compact="compact"
checked checked="checked"
declare declare="declare"
readonly readonly="readonly"
disabled disabled="disabled"
selected selected="selected"
defer defer="defer"
ismap ismap="ismap"
nohref nohref="/nohref"
noshade noshade="noshade"
nowrap nowrap="nowrap"
multiple multiple="multiple"
noresize noresize="noresize"
<img src="picture.gif" name="picture1" />
正确的代码:
<img src="picture.gif" id="picture1" />
<img src="picture.gif" id="picture1" name="picture1" />
为了适应新的浏览器浏览我们在上述代码中的最后我加了/来结束标签。