干凈的XHTML語法
2019-10-26 17:22:01
供稿:網友
Writing XHTML demands a clean HTML syntax.
寫XHTML要求使用干凈的HTML語法
--------------------------------------------------------------------------------
Some More XHTML Syntax Rules:
更多XHTML語法規則:
Attribute names must be in lower case
屬性名稱必須為小寫
Attribute values must be quoted
屬性值使用雙引號
Attribute minimization is forbidden
屬性簡寫是不允許的
The id attribute replaces the name attribute
用id屬性來替代name屬性
The XHTML DTD defines mandatory elements
XHTML DTD定義強制元素
--------------------------------------------------------------------------------
Attribute Names Must Be In Lower Case
屬性名稱必須為小寫
This is wrong:
這是錯誤的:
<table WIDTH="100%">This is correct:
這是正確的:
<table width="100%">
--------------------------------------------------------------------------------
Attribute Values Must Be Quoted
屬性值必須帶上雙引號
This is wrong:
這是錯誤的:
<table width=100%>This is correct:
這是正確的:
<table width="100%">
--------------------------------------------------------------------------------
Attribute Minimization Is Forbidden
不允許屬性簡寫
This is wrong:
這是錯誤的:
<input checked>
<input readonly>
<input disabled>
<option selected>
<frame noresize>This is correct:
正確的是這樣:
<input checked="checked" />
<input readonly="readonly" />
<input disabled="disabled" />
<option selected="selected" />
<frame noresize="noresize" />Here is a list of the minimized attributes in HTML and how they should be written in XHTML:
這是在HTML中簡寫的屬性和其在XHTML中應該怎樣書寫的列表:
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"
--------------------------------------------------------------------------------
The id Attribute Replaces The name Attribute
id屬性替換name屬性
HTML 4.01 defines a name attribute for the elements a, applet, frame, iframe, img, and map. In XHTML the name attribute is deprecated. Use id instead.
對于a, applet, frame, iframe, img和map,HTML 4.01中定義了一個name屬性,在XHTML中是不贊成這樣做的,使用id來代替。