针对初学者的XHTML基础(二)
- 2008-05-14 23:15:53
-
XHTML 的语法
简单的说写 XHTML 要用干净的 HTML 语法。
XHTML的一些其他语法要求:
属性名字必须小写。如:
错误代码:
<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" 用id属性代替name属性。如:
HTML 4.01 中为a,applet, frame, iframe, img 和 map定义了一个name属性.在 XHTML 里name属性是不能被使用的,应该用id 来替换它。如:
错误代码:
<img src="picture.gif" name="picture1" />
正确的代码:
<img src="picture.gif" id="picture1" />
注意:我们为了使旧浏览器也能正常的执行该内容我们也可以在标签中同时使用id和name属性。如:
<img src="picture.gif" id="picture1" name="picture1" />为了适应新的浏览器浏览我们在上述代码中的最后我加了/来结束标签。
- 发表评论 0评论
- >> more评论
