首頁 > web前端 > css教學 > XHTML標準語法_CSS/HTML

XHTML標準語法_CSS/HTML

WBOY
發布: 2016-05-16 12:11:21
原創
1529 人瀏覽過

写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:
这是错误的:

This is correct:
这是正确的:

--------------------------------------------------------------------------------

Attribute Values Must Be Quoted
属性值必须带上双引号
This is wrong:
这是错误的:

This is correct:
这是正确的:

--------------------------------------------------------------------------------

Attribute Minimization Is Forbidden
不允许属性简写
This is wrong:
这是错误的:







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来代替。

This is wrong:
这是错误的:

This is correct:
这是正确的:

Note: To interoperate with older browsers for a while, 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 "/" symbol.
让你的XHTML兼容当前的浏览器你应该在/标记前添加空格


-------------------------------------------------- ----------------------------------

The Lang Attribute
Lang Attribute
The lang attribute applies to almost every XHTML element. It specifies the language of the content within the element

If you use the lang attribute in an element, you must add the xml:lang attribute, like this:

If you use the lang attribute in an element, you must add the xml:lang attribute, like this: :

Heia Norge!

-------------------------------------------------- ----------------------------------

Mandatory XHTML Elements

Mandatory XHTML Elements
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.
All All XHTML documents must have a DOCTYPE statement. The html, head and body elements must appear, and the title must be in the head element

This is a minimum XHTML document template:

This is a minimum XHTML document template

">
Title goes here


Body text goes here
Note: The DOCTYPE declaration is not a part of the XHTML document itself. It is not an XHTML element, and it should not have a closing tag.
Note: The DOCTYPE declaration is not part of the XHTML document itself. It's also not an XHTML element and it shouldn't have a closing tag.

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. This is because "xmlns=http:/ /www.w3.org/1999/xhtml" is a fixed value and will be added to the tag even if you do not include it.

Note: XHTML documents require that the xmlns attribute appears in the html tag. However, w3.org's validator will not report an error because this attribute does not appear in your XHTML document. This is because "xmlns=http://www.w3.org/1999/xhtml" is a fixed value, even if it is not included in your document, it will be added automatically.

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板