首页 > 编程 > HTML > 正文

干净的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来代替。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选