分享
 
 
 

[XHTML Tutorial] 走向XHTML标准 (3)(Differences Between XHTML And HTML)

王朝html/css/js·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

原文地址:http://www.w3schools.com/xhtml/xhtml_html.asp

翻译:范维肖

You can prepare yourself for XHTML by starting to write strict HTML.

你可以通过开始书写严格的HTML代码来为你的XHML之路做准备

How To Get Ready For XHTML

如何开始XHTML呢?

XHTML is the next generation of HTML, but it will of course take some time before browsers and other software products are ready for it.

XHTML是HTML的下一代语言,当然,在新的浏览器和其他的相关软件产品出现之前,它将延迟一段时间才能普及。

In the meantime there are some important things you can do to prepare yourself for it. As you will learn from this tutorial, XHTML is not very different from HTML 4.01, so bringing your code up to 4.01 standards is a very good start. Our complete HTML 4.01 reference can help you with that.

其间,有一些重要的事情你能够去做来为它的学习做准备。就像你可以从这篇指南学到的东西一样,XHTML不是与HTML4.01有很多不同的,所以把你的代码改写程4.01标准是一种非常好的开始,我们完整的HTML4.01参考可以帮助你解决这个问题。

In addition, you should start NOW to write your HTML code in lowercase letters, and NEVER make the bad habit of skipping end tags like the </p>.

另外,现在你应该开始用小写字母来书写你的HTML代码了,并且永远不要再像以前那样有跳过像</p>这样的结尾标记的坏习惯了。

Happy coding!

陶醉于编码之中吧!

The Most Important Differences:

两者最主要的不同:

XHTML elements must be properly nested

XHTML documents must be well-formed

Tag names must be in lowercase

All XHTML elements must be closed

XHTML元素必须正确的嵌套

XHTML文档必须有良好的格式

标记的名字必须用小写字母

左右的XHTML元素都必须有关闭符

Elements Must Be Properly Nested

元素(标记)必须被正确的嵌套

In HTML some elements can be improperly nested within each other like this:

在HTML中,有些标记能够非正确的相互嵌套,就像这样:

<b><i>This text is bold and italic</b></i>

In XHTML all elements must be properly nested within each other like this:

在XHTML中所有的标记必须被正确的嵌套,像这样:

<b><i>This text is bold and italic</i></b>

Note: A common mistake in nested lists, is to forget that the inside list must be within an li element, like this:

注意:在列表嵌套的时候大家经常会犯一个错误,那就是忘记了插入的新的列表必须在一个<li>标记中,像这样

<ul>

<li>Coffee</li>

<li>Tea

<ul>

<li>Black tea</li>

<li>Green tea</li>

</ul>

<li>Milk</li>

</ul>

This is correct:

正确的写法

<ul>

<li>Coffee</li>

<li>Tea

<ul>

<li>Black tea</li>

<li>Green tea</li>

</ul>

</li>

<li>Milk</li>

</ul>

Notice that we have inserted a </li> tag after the </ul> tag in the "correct" code example.

在这段正确的代码示例中,注意到我们在</ul>之后加了一个</li>标记吗?

Documents Must Be Well-formed

文档必须格式良好

All XHTML elements must be nested within the <html> root element. All other elements can have sub (children) elements. Sub elements must be in pairs and correctly nested within their parent element. The basic document structure is:

所有的XHTML标记必须被嵌套使用在<html>根标记之中。所有其他的标记能有自己的子标记。位于父标记之内的子标记也必须成对的而且正确的嵌套使用。一个网页的基本结构是这样:

<html>

<head> ... </head>

<body> ... </body>

</html>

Tag Names Must Be In Lower Case

标记的名字必须用小写字母

This is because XHTML documents are XML applications. XML is case-sensitive. Tags like <br> and <BR> are interpreted as different tags.

这是因为XHTML文档是XML的应用程序,XML是大小写敏感的,像<br>和<BR>是会被认为为两种不共的标记的。

This is wrong:

错误的:

<BODY>

<P>This is a paragraph</P>

</BODY>

This is correct:

正确的

<body>

<p>This is a paragraph</p>

</body>

All XHTML Elements Must Be Closed

所有的XHTML标记都必须有关闭符

Non-empty elements must have an end tag.

非空的标记必须有一个关闭符。

This is wrong:

这是错误的:

<p>This is a paragraph

<p>This is another paragraph

This is correct:

这才是正确的

<p>This is a paragraph</p>

<p>This is another paragraph</p>

Empty Elements Must Also Be Closed

空标记也必须有关闭符

Empty elements must either have an end tag or the start tag must end with />.

空标记必须有关闭符或以开始符加上 />来结束

This is wrong:

错误的代码

This is a break<br>

Here comes a horizontal rule:<hr>

Here's an image <img src="happy.gif" alt="Happy face">

This is correct:

正确的:

This is a break<br />

Here comes a horizontal rule:<hr />

Here's an image <img src="happy.gif" alt="Happy face" />

IMPORTANT Compatibility Note:

关于兼容性的重要的注释:

To make your XHTML compatible with today's browsers, you should add an extra space before the "/" symbol like this: <br />, and this: <hr />.

为了使你的XHTML能够兼容现在的浏览器,你必须在/符号之前加一个特殊的空格,就像这样:<br /><hr />

(转载请注明出处)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有