分享
 
 
 

[XHTML Tutorial] 走向XHTML标准 (6)(XHTML HOWTO)

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

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

翻译:范维肖

XHTML HowTo

如何将我现有的网站转换成XHTML的呢?

To convert a Web site from HTML to XHTML, you should be familiar with the XHTML syntax rules of the previous chapters. The following steps were executed (in the order listed below):

将一个HTML网站转换到XHTML,你应该熟悉前几章介绍的XHTML的语法规则。下面的内容将帮助您。

A DOCTYPE Definition Was Added

The following DOCTYPE declaration was added as the first line of every page:

将下面的这行代码加到每一页的第一行。

<!DOCTYPE html PUBLIC

"-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Note that we used the transitional DTD. We could have chosen the strict DTD, but found it a little too "strict", and a little too hard to conform to.

注意哦,这里我们使用的是transtitional DTD。当然我们也可以选择Strict DTD的,但是我们发现它有点太严格了,要想完全的去遵循它太难了。

A Note About The DOCTYPE

Your pages must have a DOCTYPE declaration if you want them to validate as correct XHTML.

如果你想使你的页面满足正确的XHTML的有效性你就必须使用DOCTYPE声明。

Be aware however, that newer browsers (like Internet Explorer 6) might treat your document differently depending on the <!DOCTYPE> declaration. If the browser reads a document with a DOCTYPE, it might treat the document as "correct". Malformed XHTML might fall over and display differently than without a DOCTYPE.

然而你必须注意到,比较新的浏览器(像IE6)看到你的页面里的DOCTYPE声明后可能会有不同的对待。如果浏览器读到一个含有DOCTYPE声明的页面,它或许会把这个页面认为“正确的”。如果不使用DOCTYPE的畸形XHTML页面可能会使上面的元素”掉下来“并显示初一个不一样的页面。

Lower Case Tag And Attribute Names

Since XHTML is case sensitive, and since XHTML only accepts lower case HTML tags and attribute names, a general search and replace function was executed to replace all upper case tags with lowercase tags. The same was done for attribute names. We have always tried to use lower case names in our Web, so the replace function did not produce many real substitutions.

XHTML是大小写敏感的,并且只接受小写标记和属性名,你可以使用替换功能来处理。

All Attributes Were Quoted

Since the W3C XHTML 1.0 Recommendation states that all attribute values must be quoted, every page in the web was checked to see that attributes values were properly quoted. This was a time-consuming job, and we will surely never again forget to put quotes around our attribute values.

属性要用括号引起来,这个没有什么简便方法了,却是是项耗时间的工作,只要记得以后别忘了括号就行了。

Empty Tags: <hr> , <br> and <img>

Empty tags are not allowed in XHTML. The <hr> and <br> tags should be replaced with <hr /> and <br />.

This produced a problem with Netscape that misinterpreted the <br/> tags. We don't know why, but changing it to <br /> worked fine. After that discovery, a general search and replace function was executed to swap the tags.

A few other tags (like the <img> tag) were suffering from the same problem as above. We decided not to close the <img> tags with </img>, but with /> at the end of the tag. This was done manually.

太罗嗦了。就是说有关标记嘛The Web Site Was Validated

After that, all pages were validated against the official W3C DTD with this link: XHTML Validator. A few more errors were found and edited manually. The most common error was missing </li> tags in lists.

你的网站可以通过官方的XHTML有效性检查器来被验证,更多的错误会被检查出并且手工边界,而最通常的错误就是在list里忘记了写</li>了。

Should we have used a converting tool? Well, we could have used TIDY.

可以使用TIDY这个转换工具

Dave Raggett's HTML TIDY is a free utility for cleaning up HTML code. It also works great on the hard-to-read markup generated by specialized HTML editors and conversion tools, and it can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities.

Dave Raggett 的HTML TIDY是一个用来优化HTML代码免费软件,它也能很好的处理那些由特殊的HTML编辑器和转换工具产生的难以理解的标记,同时,它能帮助你标识那些你必须从长远的角度来注意的你的页面能否被残疾人士所使用呢?

The reason why we didn't use Tidy? We knew about XHTML when we started writing this web site. We knew that we had to use lowercase tag names and that we had to quote our attributes. So when the time came (to do the conversion), we simply had to test our pages against the W3C XHTML validator and correct the few mistakes. AND - we have learned a lot about writing "tidy" HTML code.

我们不使用TIDY的原因是当我们做这个网站的时候我们就知道XHTML了,小写和引号我们也知道了。所以当需要转换的时候我们只是简单的通过W3C的XHTML验证器来改正我们的少数的错误。并且,我们已经懂得了要书写干净的HTML代码的。

A DOCTYPE Definition Was Added

The following DOCTYPE declaration was added as the first line of every page:

将下面的这行代码加到每一页的第一行。

<!DOCTYPE html PUBLIC

"-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Note that we used the transitional DTD. We could have chosen the strict DTD, but found it a little too "strict", and a little too hard to conform to.

注意哦,这里我们使用的是transtitional DTD。当然我们也可以选择Strict DTD的,但是我们发现它有点太严格了,要想完全的去遵循它太难了。

A Note About The DOCTYPE

Your pages must have a DOCTYPE declaration if you want them to validate as correct XHTML.

如果你想使你的页面满足正确的XHTML的有效性你就必须使用DOCTYPE声明。

Be aware however, that newer browsers (like Internet Explorer 6) might treat your document differently depending on the <!DOCTYPE> declaration. If the browser reads a document with a DOCTYPE, it might treat the document as "correct". Malformed XHTML might fall over and display differently than without a DOCTYPE.

然而你必须注意到,比较新的浏览器(像IE6)看到你的页面里的DOCTYPE声明后可能会有不同的对待。如果浏览器读到一个含有DOCTYPE声明的页面,它或许会把这个页面认为“正确的”。如果不使用DOCTYPE的畸形XHTML页面可能会使上面的元素”掉下来“并显示初一个不一样的页面。

Lower Case Tag And Attribute Names

Since XHTML is case sensitive, and since XHTML only accepts lower case HTML tags and attribute names, a general search and replace function was executed to replace all upper case tags with lowercase tags. The same was done for attribute names. We have always tried to use lower case names in our Web, so the replace function did not produce many real substitutions.

XHTML是大小写敏感的,并且只接受小写标记和属性名,你可以使用替换功能来处理。

All Attributes Were Quoted

Since the W3C XHTML 1.0 Recommendation states that all attribute values must be quoted, every page in the web was checked to see that attributes values were properly quoted. This was a time-consuming job, and we will surely never again forget to put quotes around our attribute values.

属性要用括号引起来,这个没有什么简便方法了,却是是项耗时间的工作,只要记得以后别忘了括号就行了。

Empty Tags: <hr> , <br> and <img>

Empty tags are not allowed in XHTML. The <hr> and <br> tags should be replaced with <hr /> and <br />.

This produced a problem with Netscape that misinterpreted the <br/> tags. We don't know why, but changing it to <br /> worked fine. After that discovery, a general search and replace function was executed to swap the tags.

A few other tags (like the <img> tag) were suffering from the same problem as above. We decided not to close the <img> tags with </img>, but with /> at the end of the tag. This was done manually.

太罗嗦了。就是说有关标记嘛The Web Site Was Validated

After that, all pages were validated against the official W3C DTD with this link: XHTML Validator. A few more errors were found and edited manually. The most common error was missing </li> tags in lists.

你的网站可以通过官方的XHTML有效性检查器来被验证,更多的错误会被检查出并且手工边界,而最通常的错误就是在list里忘记了写</li>了。

Should we have used a converting tool? Well, we could have used TIDY.

可以使用TIDY这个转换工具

Dave Raggett's HTML TIDY is a free utility for cleaning up HTML code. It also works great on the hard-to-read markup generated by specialized HTML editors and conversion tools, and it can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities.

Dave Raggett 的HTML TIDY是一个用来优化HTML代码免费软件,它也能很好的处理那些由特殊的HTML编辑器和转换工具产生的难以理解的标记,同时,它能帮助你标识那些你必须从长远的角度来注意的你的页面能否被残疾人士所使用呢?

The reason why we didn't use Tidy? We knew about XHTML when we started writing this web site. We knew that we had to use lowercase tag names and that we had to quote our attributes. So when the time came (to do the conversion), we simply had to test our pages against the W3C XHTML validator and correct the few mistakes. AND - we have learned a lot about writing "tidy" HTML code.

我们不使用TIDY的原因是当我们做这个网站的时候我们就知道XHTML了,小写和引号我们也知道了。所以当需要转换的时候我们只是简单的通过W3C的XHTML验证器来改正我们的少数的错误。并且,我们已经懂得了要书写干净的HTML代码的。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
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- 王朝網路 版權所有