首頁  >  文章  >  web前端  >  乾淨的XHTML語法_HTML/Xhtml_網頁製作

乾淨的XHTML語法_HTML/Xhtml_網頁製作

WBOY
WBOY原創
2016-05-16 16:45:281011瀏覽

Writing XHTML demands a clean HTML syntax.
寫XHTML要求使用乾淨的HTML語法
---------------------------- -------------------------------------------------- --
Some More XHTML Syntax Rules:
更多XHTML語法規則:
Attribute names must be in lower case
屬性名稱必須為小寫
Attribute values be quoted
屬性值使用雙引號
Attribute minimization is forbidden
屬性簡寫是不允許的
The id attribute replace the name the name >
用id屬性來取代name屬性The XHTML DTD defines mandatory elements
XHTML DTD定義強制元素
---------------- -------------------------------------------------- --------------
Attribute Names Must Be In Lower Case
屬性名稱必須為小寫
This is wrong:
這是錯誤的:

This is correct:

這是正確的:

-------------------------- -------------------------------------------------- ----
Attribute Values Must Be Quoted
屬性值必須帶雙引號
This is wrong:
這是錯誤的:

This is correct:

這是正確的:

------------------------------------ ----------------------------------------------
Attribute Minimization Is Forbidden
不允許屬性簡寫
This is wrong:
這是錯的:





This is correct:
正確的是這樣:










of list 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"
se ="defer"
ismap ismap="ismap"
nohref nohref="nohref"乾淨的XHTML語法_HTML/Xhtml_網頁製作noshade noshade="noshade"
nowrap nowrap="nowrap"
multiple multiple="multiple 🎜>noresize noresize="noresize"乾淨的XHTML語法_HTML/Xhtml_網頁製作
------------------------------------ --------------------------------------------
The id Attribute Replaces The name Attribute乾淨的XHTML語法_HTML/Xhtml_網頁製作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 is. 🎜>對於a, applet, frame, iframe, img和map,HTML 4.01中定義了一個name屬性,在XHTML中是不贊成這樣做的,使用id來代替。
This is wrong:
這是錯的:

This is correct:
這是正確的:

while: To interoperate with older broers for aile,
while: To interoperate with older broers for aile, you should use both name and id, with identical attribute values, like this:
注意:為了版本比較低的瀏覽器,你應該同時使用name和id屬性,並使它們兩個的值相同的,像這樣:

IMPORTANT Compatibility Note:
相容性注意:
To make your XHTML compatible with today''s browsers, you should add an extra space before the "/" symbolers讓你的XHTML相容當前的瀏覽器你應該在/標記前加上空格--------------------------- -------------------------------------------------- ---The Lang AttributeLang 屬性The lang attribute applies to almost every XHTML element. It specifies the language of the content within an element.HTlang屬性可以應用於幾乎所有的XHTML元素。它指定了元素中內容的語言If you use the lang attribute in an element, you must add the xml:lang attribute, like this:如果你像在一個元素中應用lang屬性,你必須加上xml:lang屬性,像這樣:Heia Norge!
----------------------------------------------- ---------------------------------
Mandatory XHTML Elements
強制XHTML元素
All XHTML documents must have a DOCTYPE declaration. The html, head and body elements must be present, and the title must be present inside the head element.
所有的XHTML文件都必須有一個DOCTYPE聲名。 html、head和body元素必須出現,而title必須在head元素裡
This is a minimum XHTML document template:
這是一個極小的XHTML文件模板
oes here>


Title goes here

Body text goes here
Body text goes here

Body text goes here
Note: not a part of the XHTML document itself. It is not an XHTML element, and it should not have a closing tag.
注意:DOCTYPE聲明並不是XHTML文檔本身的一部分。它也不是XHTML元素,它不該有關閉標籤。 Note: The xmlns attribute inside the tag is required in XHTML. However, the validator on w3.org does not complain when this attribute is missing in an XHTML document. Thisxml be attribute is missing in an XHTML document. Thisxml bebem. www.w3.org/1999/xhtml" is a fixed value and will be added to the tag even if you do not include it.注意:XHTML文件要求xmlns屬性出現在html標籤中。然而,w3.org的校驗器不會因為這個屬性沒有出現在你的XHTML文件中而報告錯誤。這是因為"xmlns=http://www.w3.org/1999/xhtml"是一個固定的值,即使你的文件裡沒有包含它,它也會自動加上的。 You will learn more about the XHTML document type definition in the next chapter
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn