首頁  >  文章  >  web前端  >  HTML和XHTML的差別

HTML和XHTML的差別

王林
王林轉載
2023-08-20 22:17:341966瀏覽

HTML和XHTML的差別

HTML和XHTML是用來開發網頁的電腦語言。它具有簡單的語法,易於理解。 XHTML是HTML的擴展,也結合了XML的特性。它比HTML有更嚴格的語法。儘管XHTML是從HTML衍生出來的,但這兩者之間有相當大的差異。

什麼是HTML?

HTML的全名為超文本標記語言。它是由Tim Berners Lee於1993年開發的。它是標準通用標記語言(SGML)的擴展形式。 HTML為網頁開發提供了基礎或骨架。

超文本是透過超連結將一個頁面連結到另一個頁面,並在點擊時啟動的文字。標記語言是使用標籤來設計網頁並使其看起來更具吸引力的語言。超文本標記語言用於從基本層級連接多個頁面開發網頁。

所有的元素在html中都是透過html標籤來定義的。標籤就像是關鍵字,幫助以不同的格式排列元素。 HTML不是一種程式語言。

優勢

  • 這很簡單,初學者也能輕鬆理解

  • HTML被所有瀏覽器支援

  • 它可以在任何作業系統上運行,因此具有平台無關性

  • 它是免費的,並且在Windows中預設可用

  • #It is light weighted and loads faster

  • 它的文法很容易學習

  • 它可以輕鬆地與CSS、JavaScript和其他語言整合

Disadvantages

  • 它無法產生動態輸出

  • #Even a simple webpage requires number of lines of code

  • #It doesn’t provide security

  • Even there is an error in the syntax, it runs it. But we don’t get the desired output

  • 我們不能只使用HTML來建立完整的網頁。它只能建立基本的網頁

What is XHTML?

XHTML stands for Extensible hypertext markup language. It was developed by World Wide Web Consortium (W3C) and released in the year 2000. It has the characteristics of both HTML and XML.

它與HTML幾乎相似,但比HTML嚴格得多。 XHTML的主要原因是HTML在保護其原始碼方面過於寬鬆。 XHTML更靈活,可以輕鬆轉換成其他格式。

Every XHTML document consists of three main parts. They are −

  • DOCTYPE − Used to declare the type of document

  • Head − 用於宣告標題和其他屬性

  • Body − Part that consist of the actual content that a web page contains

優勢

  • It follows strict rules hence reducing errors

  • #它讓程式碼易讀

  • #它提供了更多的安全性,原始碼不容易被存取

  • #As it follows all the rules of XML, it is easy to convert to other formats

  • All web applications are moving towards XML. Hence it is good to use XHTML than HTML as it has more scope in future

  • 使用此工具建立的網頁具有可移植性。它的簡單性使其能在處理器較小的設備上運行

Disadvantages

  • Beginners find it difficult to learn

  • Only few browsers support XHTML. Hence its practical use is limited

#HTML vs XHTML

The following table highlights the major differences between HTML and XHTML −

參數

HTML

XHTML

#Full form

HTML stands for Hyper Text Markup Language

XHTML代表可擴充超文本標記語言

#Developed by

#HTML was developed by Tim Berners Lee

XHTML was developed by World Wide Web Consortium (W3C)

Release date

#It was released in 1993

#It was released in 2000

#File format

It is of document type file format

它是以標記語言檔案格式儲存的

Extended from

#HTML是從SGML(標準通用標記語言)擴展而來的

It is extended from HTML and XML (Extensible markup language)

File extension

#It has the file extensions - .html, .htm

#它有副檔名 - .xhtml,.xht,.html,.htm,.xml

Case sensitivity

HTML is not case sensitive. It can be written in upper case or lowercase or a combination of both

XHTML is case sensitive. All the code should be in lower case

DOCTYPE

在HTML中,每個頁面的開頭不需要新增

#在XHTML中,每個頁面的頂部都必須提及

閉合標籤

In HTML, it is not mandatory to close the tags

#在XHTML中,關閉所有標籤是強制性的

#屬性

While writing attributes in HTML, it is not necessary to mention them in double quotes

Ex :-

#需要在引號中提及屬性值

Ex :-

#Nesting

不需要巢狀元素

#In XHTML, elements should be nested properly in an order

嚴格性

HTML is lenient compared to XHTML

XHTML strictly follows rules

Structure of code

#它的程式碼不夠有組織性

它有更有組織的程式碼

錯誤

即使其中包含錯誤,它仍然可以運行程式碼

它嚴格檢查所有錯誤

#解析

Its source code can be accessed easily

存取其原始程式碼有些困難

安全

HTML不夠安全

#XHTML provides more security

#瀏覽器相容性

HTML被所有瀏覽器支援

Only few browsers support XHTML

Complexity

It has simple syntax and can be understood easily

Beginners find it difficult to understand

結論

HTML和XHTML的主要目標是建立網頁。 XHTML是HTML的擴充版本,它遵循更多規則,並且相對於HTML來說更加嚴格。 XHTML可以輕鬆轉換成其他資料格式。

以上是HTML和XHTML的差別的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除