登录  /  注册

干净的XHTML语法_HTML/Xhtml_网页制作

php中文网
发布: 2016-05-16 16:45:28
原创
882人浏览过

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

This is correct:
这是正确的:

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

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




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:
这是错误的:
干净的XHTML语法_HTML/Xhtml_网页制作This is correct:
这是正确的:
干净的XHTML语法_HTML/Xhtml_网页制作Note: To interoperate with older browsers for a while, you should use both name and id, with identical attribute values, like this:
注意:为了版本比较低的浏览器,你应该同时使用name和id属性,并使它们两个的值相同的,像这样:
干净的XHTML语法_HTML/Xhtml_网页制作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属性,像这样:
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
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 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.
注意: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
智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号