加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程 > 正文

干净的XHTML语法

发布时间:2020-03-16 15:39:34 所属栏目:编程 来源:站长网
导读:Writing XHTML demands a clean HTML syntax. 写XHTML要求行使干净的HTML语法 -------------------------------------------------------------------------------- Some More XHTML Syntax Rules: 更多XHTML语礼貌则: Attribute names must be in lower c
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来取代。
This is wrong:
这是错误的:
<img src=http://www.jb51.net/web/"picture.gif" name="picture1" />This is correct:
这是正确的:
<img src=http://www.jb51.net/web/"picture.gif" id="picture1" />Note: To interoperate with older browsers for a while, you should use both name and id, with identical attribute values, like this:
留意:为了版本较量低的赏识器,你应该同时行使name和id属性,并使它们两个的值沟通的,像这样:
<img src=http://www.jb51.net/web/"picture.gif" id="picture1" name="picture1" />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.
lang属性可以应用于险些全部的XHTML元素。它指定了元素中内容的说话
If you use the lang attribute in an element, you must add the xml:lang attribute, like this:
假如你像在一个元素中应用lang属性,你必需加上xml:lang属性,像这样:
<div lang="no" xml:lang="no">Heia Norge!</div>
--------------------------------------------------------------------------------
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文档模板
<!DOCTYPE Doctype goes here>
<html xmlns="">
<head>
<title>Title goes here</title>
</head><body>
Body text goes here
</body></html>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 <html> 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 <html> 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

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读