首页 » 建站技术 » 浏览内容

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


2005-02-02 08:39:22 5,256 0 发表评论 字体: 作者:C.K.
标签: xhtml

体验版 88 元,个人版 128 元,多用户版 288元个人版160元升级到多用户版。

原文地址: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

.
另外,现在你应该开始用小写字母来书写你的HTML代码了,并且永远不要再像以前那样有跳过像

这样的结尾标记的坏习惯了。
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中,有些标记能够非正确的相互嵌套,就像这样:


This text is bold and italic

In XHTML all elements must be properly nested within each other like this:
在XHTML中所有的标记必须被正确的嵌套,像这样:

This text is bold and italic

Note: A common mistake in nested lists, is to forget that the inside list must be within an li element, like this:
注意:在列表嵌套的时候大家经常会犯一个错误,那就是忘记了插入的新的列表必须在一个

  • 标记中,像这样

    • Coffee
    • Tea

      • Black tea
      • Green tea

    • Milk

    This is correct:

    正确的写法

    • Coffee
    • Tea

      • Black tea
      • Green tea

    • Milk


    Notice that we have inserted a

  • tag after the

    tag in the “correct” code example.
    在这段正确的代码示例中,注意到我们在

    之后加了一个

    标记吗?


    Documents Must Be Well-formed
    文档必须格式良好
    All XHTML elements must be nested within the 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标记必须被嵌套使用在根标记之中。所有其他的标记能有自己的子标记。位于父标记之内的子标记也必须成对的而且正确的嵌套使用。一个网页的基本结构是这样:








    Tag Names Must Be In Lower Case
    标记的名字必须用小写字母
    This is because XHTML documents are XML applications. XML is case-sensitive. Tags like
    and
    are interpreted as different tags.
    这是因为XHTML文档是XML的应用程序,XML是大小写敏感的,像

    是会被认为为两种不共的标记的。

    This is wrong:
    错误的:


    This is a paragraph



    This is correct:
    正确的


    This is a paragraph



    All XHTML Elements Must Be Closed
    所有的XHTML标记都必须有关闭符
    Non-empty elements must have an end tag.
    非空的标记必须有一个关闭符。
    This is wrong:
    这是错误的:



    This is a paragraph

    This is another paragraph
    这才是正确的

    This is a paragraph

    This is another paragraph

    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

    Here comes a horizontal rule:


    Here's an image Happy face

    This is correct:
    正确的:


    This is a break

    Here comes a horizontal rule:


    Here's an image 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:
    , and this:


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


    网站统计 Statistics

    • 创建时间: 2005年1月3日 距今5041 天
    • 日志总数: 2461
    • 评论总数: 630
    • 标签总数: 654
    • 链接总数: 273
    • 最后更新: 2018-8-31 17:57:04
    • 您是本站第 14060460 位访客

    广告区 Guǎng Gào