XHTML standard syntax_CSS/HTML

WBOY
Release: 2016-05-16 12:11:21
Original
1510 people have browsed it

写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 屬性
The lang attribute applies to almost every XHTML element. It specifies the language of the content within an element.
屬性可以應用於幾乎所有的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 所有.的XHTML文件都必須有一個DOCTYPE聲名。 html、head和body元素必須出現,而title必須在head元素裡

This is a minimum XHTML document template:

這是一個極小的XHTML文件範本

oes here>

">


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.
注意: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. This is. 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"是一個固定的值,即使你的文件裡沒有包含它,它也會自動加上的。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template