HTML和XHTML是用于开发网页的计算机语言。它具有简单的语法,易于理解。XHTML是HTML的扩展,还结合了XML的特性。它比HTML有更严格的语法。尽管XHTML是从HTML派生出来的,但这两者之间存在相当大的区别。
HTML的全称是超文本标记语言。它是由Tim Berners Lee于1993年开发的。它是标准通用标记语言(SGML)的扩展形式。HTML为网页开发提供了基础或骨架。
超文本是通过超链接将一个页面链接到另一个页面,并在点击时激活的文本。标记语言是使用标签来设计网页并使其看起来更具吸引力的语言。超文本标记语言用于从基本级别连接多个页面开发网页。
所有的元素在html中都是通过html标签来定义的。标签就像是关键字,帮助以不同的格式排列元素。HTML不是一种编程语言。
这很简单,初学者也能轻松理解
HTML被所有浏览器支持
它可以在任何操作系统上运行,因此具有平台无关性
它是免费的,并且在Windows中默认可用
It is light weighted and loads faster
它的语法很容易学习
它可以轻松地与CSS、JavaScript和其他语言集成
它无法生成动态输出
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来创建完整的网页。它只能创建基本的网页
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
使用此工具创建的网页具有可移植性。它的简单性使其能在处理器较小的设备上运行
Beginners find it difficult to learn
Only few browsers support XHTML. Hence its practical use is limited
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中文网其他相关文章!