首頁 web前端 css教學 XHTML與HTML之間的差異_CSS/HTML

XHTML與HTML之間的差異_CSS/HTML

May 16, 2016 pm 12:11 PM

翻译:Linyupark

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相差不多,所以把你的代码改写成符合HTML4.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元素必须合理嵌套
XHTML documents must be well-formed
XHTML文档必须格式正确
Tag names must be in lowercase
标签名称必须是小写
All XHTML elements must be closed
所有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 italicIn XHTML all elements must be properly nested within each other like this:
在XHTML所有元素必须合理的相互嵌套像这样:

This text is bold and italicNote: A common mistake in nested lists, is to forget that the inside list must be within a 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
    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.
    This is because the XHTML document is an XML application, and XML is case-sensitive, such as
    and
    will be considered two different tags.

    This is wrong:
    This is wrong:


    This is a paragraph


    This is correct:
    This is correct:


    This is a paragraph


    -------------------------------------------------- ----------------------------------

    All XHTML Elements Must Be Closed
    All XHTML elements must be closed
    Non-empty elements must have an end tag.
    Non-empty elements must have an end tag.

    This is wrong:
    This is wrong:

    This is a paragraph

    This is another paragraphThis is correct:
    Correct is this:

    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 />.
    Empty elements must also have an End tags or opening tags end with />.

    This is wrong:

    This is wrong:

    This is a break

    Here comes a horizontal rule:



    Here''''s an image Happy faceThis is correct:
    This is correct:

    This is a break

    Here comes a horizontal rule:
    Here''''s an image Happy face

    IMPORTANT Compatibility Note:
    Note the key to compatibility:
    To make your XHTML compatible with today''''s browsers, you should add an extra space before the "/" symbol like this:
    , and this:


    .
    To make your XHTML compatible with modern browsers, you must add a special space before the / symbol, like this:
    and like this:


    本網站聲明
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

    熱AI工具

    Undresser.AI Undress

    Undresser.AI Undress

    人工智慧驅動的應用程序,用於創建逼真的裸體照片

    AI Clothes Remover

    AI Clothes Remover

    用於從照片中去除衣服的線上人工智慧工具。

    Undress AI Tool

    Undress AI Tool

    免費脫衣圖片

    Clothoff.io

    Clothoff.io

    AI脫衣器

    Video Face Swap

    Video Face Swap

    使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

    熱工具

    記事本++7.3.1

    記事本++7.3.1

    好用且免費的程式碼編輯器

    SublimeText3漢化版

    SublimeText3漢化版

    中文版,非常好用

    禪工作室 13.0.1

    禪工作室 13.0.1

    強大的PHP整合開發環境

    Dreamweaver CS6

    Dreamweaver CS6

    視覺化網頁開發工具

    SublimeText3 Mac版

    SublimeText3 Mac版

    神級程式碼編輯軟體(SublimeText3)

    熱門話題

    Java教學
    1664
    14
    CakePHP 教程
    1422
    52
    Laravel 教程
    1316
    25
    PHP教程
    1267
    29
    C# 教程
    1239
    24
    Google字體可變字體 Google字體可變字體 Apr 09, 2025 am 10:42 AM

    我看到Google字體推出了新設計(Tweet)。與上一次大型重新設計相比,這感覺更加迭代。我幾乎無法分辨出區別

    如何使用HTML,CSS和JavaScript創建動畫倒計時計時器 如何使用HTML,CSS和JavaScript創建動畫倒計時計時器 Apr 11, 2025 am 11:29 AM

    您是否曾經在項目上需要一個倒計時計時器?對於這樣的東西,可以自然訪問插件,但實際上更多

    HTML數據屬性指南 HTML數據屬性指南 Apr 11, 2025 am 11:50 AM

    您想了解的有關HTML,CSS和JavaScript中數據屬性的所有信息。

    使Sass更快的概念證明 使Sass更快的概念證明 Apr 16, 2025 am 10:38 AM

    在一個新項目開始時,Sass彙編發生在眼睛的眨眼中。感覺很棒,尤其是當它與browsersync配對時,它重新加載

    我們如何創建一個在SVG中生成格子呢模式的靜態站點 我們如何創建一個在SVG中生成格子呢模式的靜態站點 Apr 09, 2025 am 11:29 AM

    格子呢是一塊圖案布,通常與蘇格蘭有關,尤其是他們時尚的蘇格蘭語。在Tar​​tanify.com上,我們收集了5,000多個格子呢

    如何在WordPress主題中構建VUE組件 如何在WordPress主題中構建VUE組件 Apr 11, 2025 am 11:03 AM

    內聯式模板指令使我們能夠將豐富的VUE組件構建為對現有WordPress標記的逐步增強。

    當您看上去時,CSS梯度變得更好 當您看上去時,CSS梯度變得更好 Apr 11, 2025 am 09:16 AM

    我關注的一件事是Lea Verou' s conic-Gradient()Polyfill的功能列表是最後一項:

    靜態表單提供商的比較 靜態表單提供商的比較 Apr 16, 2025 am 11:20 AM

    讓我們嘗試在這裡造成一個術語:“靜態表單提供商”。你帶上html

    See all articles