XHTML教程:针对初学者的XHTML基础
XHTML 的语法
简单的说写 XHTML 要用干净的 HTML 语法。
XHTML的一些其他语法要求:
属性名字必须小写。如: Webjx.Com
错误代码:
<table WIDTH="100%">
正确的代码: Webjx.Com
<table width="100%">
属性值必须要被引用。如:
错误的代码:
网页教学网
<table width=100%>
正确的代码: 网页教学网
<table width="100%">
属性的缩写被禁止。如:
错误的代码:
<dl compact>
Webjx.Com
<input checked> Webjx.Com
<input readonly> 网页教学网
<input disabled>
<option selected> 网页教学网
<frame noresize>
正确的代码:
<dl compact="compact">
<input checked="checked" />
<input readonly="readonly" />
<input disabled="disabled" />
<option selected="selected" /> Webjx.Com
<frame noresize="noresize" /> 网页教学网
列出一个表让大家知道:
HTML XHTML 网页教学网
compact compact="compact"
checked checked="checked"
declare declare="declare"
Webjx.Com
readonly readonly="readonly" 网页教学网
disabled disabled="disabled"
selected selected="selected"
defer defer="defer" Webjx.Com
ismap ismap="ismap"
nohref nohref="nohref"
noshade noshade="noshade"
nowrap nowrap="nowrap"
Webjx.Com
multiple multiple="multiple"
Webjx.Com
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" /> Webjx.Com
为了适应新的浏览器浏览我们在上述代码中的最后我加了/来结束标签。






文章评论
共有 0 位网友发表了评论 查看完整内容