源码网,源码论坛,源码之家,商业源码,游戏源码下载,discuz插件,棋牌源码下载,精品源码论坛

 找回密码
 立即注册
查看: 770|回复: 22

[CSS/HTML] XHTML标准语法

[复制链接]

7万

主题

861

回帖

32万

积分

论坛元老

Rank: 8Rank: 8

积分
329525
发表于 2006-9-25 00:00:00 | 显示全部楼层 |阅读模式

写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="picture.gif" name="picture1" />This is correct:
这是正确的:

<img src="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="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="http://www.w3.org/1999/xhtml">
<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"是一个固定的值,即使你的文档里没有包含它,它也会自动加上的。

回复

使用道具 举报

0

主题

1万

回帖

100

积分

注册会员

Rank: 2

积分
100
发表于 2022-8-11 17:41:17 | 显示全部楼层
看看看看
回复 支持 反对

使用道具 举报

1

主题

1万

回帖

207

积分

中级会员

Rank: 3Rank: 3

积分
207
发表于 2022-8-13 11:49:10 | 显示全部楼层
554411515451555
回复 支持 反对

使用道具 举报

3

主题

1万

回帖

50

积分

注册会员

Rank: 2

积分
50
发表于 2022-9-17 21:55:27 | 显示全部楼层
管灌灌灌灌灌灌灌灌灌灌
回复 支持 反对

使用道具 举报

8

主题

1万

回帖

52

积分

注册会员

Rank: 2

积分
52
发表于 2022-12-16 19:27:45 | 显示全部楼层
终于找到了,我擦
回复 支持 反对

使用道具 举报

3

主题

1万

回帖

156

积分

注册会员

Rank: 2

积分
156
发表于 2023-2-5 08:24:39 | 显示全部楼层
啦啦啦啦啦啦哈哈哈
回复 支持 反对

使用道具 举报

27

主题

1万

回帖

331

积分

中级会员

Rank: 3Rank: 3

积分
331
发表于 2023-2-9 21:39:20 | 显示全部楼层
好人好人好人好人
回复 支持 反对

使用道具 举报

16

主题

1万

回帖

376

积分

中级会员

Rank: 3Rank: 3

积分
376
发表于 2023-3-8 19:26:00 | 显示全部楼层
你们谁看了弄洒了可能
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-4-1 05:58:30 | 显示全部楼层
老大你好你好好你好
回复 支持 反对

使用道具 举报

12

主题

1万

回帖

431

积分

中级会员

Rank: 3Rank: 3

积分
431
发表于 2023-5-4 08:23:21 | 显示全部楼层
dfdsafdsfdsfdsf
回复 支持 反对

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

手机版|小黑屋|网站地图|源码论坛 ( 海外版 )

GMT+8, 2024-9-20 08:42 , Processed in 0.083247 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表