什么语⾔能替代HTML,替代HTML的下⼀代WEB标记语⾔
XHTML
最近开始逐渐在开发Web项⽬中使⽤更加规范的XHTML来替换html,收集整理了⼀些XHTML的资料和⼤家分享。
本⽂是针对W3C相关规范⽂章资料的翻译。
XHTML 介绍
XHTML is a stricter and cleaner version of HTML.
XHTML是更严密代码更整洁的HTML版本
What Is XHTML?
XHTML是什么?
XHTML是具有延伸性的超⽂本标记语⾔网页设计html代码翻译
出现XHTML⽬的就是要替代HTML
XHTML和HTML4.01⼏乎相同
XHTML是更严密代码更整洁的HTML版本
XHTML的定义形同将HTML视为XML(从代码的结构上)
XHTML是W3C的推荐标准
What You Should Already Know
学习前你应该知道些什么
Before you continue you should have a basic understanding of the following:
在继续你的学习前你应该有下列知识的基础:
HTML and the basics of building web pages
HTML和基本的WEB页⾯建⽴能⼒
If you want to study HTML first, please read our HTML tutorial.
如果你想先学习HTML,请查阅我们的 HTML 教程.
XHTML is a W3C Recommendation
XHTML是W3C组织推荐的语⾔
XHTML 1.0 became a W3C Recommendation January 26, 2000.
2000 年1⽉26 ⽇XHTML1.0成为W3C组织推荐的⼀种语⾔
A W3C Recommendation means that the specification is stable, that it has been reviewed by the W3C membership, and that the specification is now a Web standard.
W3C推荐就意味它是稳定的,并被W3C组织的成员所审核,这已经是现在WEB的⼀个标准了。
W3C defines XHTML as the latest version of HTML. XHTML will gradually replace HTML.
W3C将XHTML定义为HTML的最新版本。XHTML将逐渐替代HTML
Stay updated with the latest web standards with our W3C tutorial.
WEB标准的最新和更新信息尽在我们的 W3C 教程
All New Browsers Support XHTML
所有新型的浏览器都⽀持XHTML
XHTML is compatible with HTML 4.01.
XHTML与HTML4.01是兼容的
All new browsers have support for XHTML.
所有新型的浏览器都⽀持XHTML
W3Schools Has Converted To XHTML
W3S⽹站已经转换成XHTML
XHTML is a reformulation of HTML 4.01 in XML, and can be put to immediate use with existing browsers by following a few simple guidelines.
XHTML是XML形式的HTML4.01,可以通过⼀些指⽰直接⽤于现有的浏览器中。
W3Schools was completely rewritten to XHTML 1.0 in 1999.
W3S在1999年完整的重构成XHTML1.0
A click on this symbol:
validates the XHTML part of this page.
单击这个标志来检验这个页是否符合XHTML
A click on this symbol:
validates the CSS part of this page.
检验CSS部分
为什么使⽤XHTML
XHTML is a combination of HTML and XML (EXtensible Markup Language).
XHTML是HTML和XML的组合 (可扩展标记语⾔)
XHTML consists of all the elements in HTML 4.01 combined with the syntax of XML.
XHTML结合XML的语法包括所有HTML4.01的元素。
Why XHTML?
为什么使⽤XHTML?
We have reached a point where many pages on the WWW contain “bad” HTML.
在万维⽹我们常会到⼀些许多页包含“糟糕的”HTML
The following HTML code will work fine if you view it in a browser, even if it does not follow the HTML rules:
下⾯的HTML代码在浏览器中运作依然正常,即使它没有遵循HTML规则
[coolcode lang=”html”]
This is bad HTML
Bad HTML
[/coolcode]
XML is a markup language where everything has to be marked up correctly, which results in “well-formed” documents.
XML是⼀种标记合理的语⾔,产⽣“合格的”⽂档。
XML was designed to describe data and HTML was designed to display data.
XML设计成描述数据⽽HTML设计成显⽰数据。
Today’s market consists of different browser technologies, some browsers run Internet on computers, and some
browsers run Internet on mobile phones and hand helds. The last-mentioned do not have the resources or power to
interpret a “bad” markup language.
今⽇市场包括不同的浏览器技术,⼀些浏览器运作在⽹上的电脑,⼀些运作在可上⽹的⼿机和⼿提电脑上,最后要说明的是它们都没有⾜够的资源或能去解释⼀种“糟糕的”标记语⾔
Therefore – by combining HTML and XML, and their strengths, we got a markup language that is useful now and in the future – XHTML.
因此,通过HTML和XML的结合,发挥它们各⾃的长处,我们获得了现在并且在将来都实⽤的标记语⾔-XHTML
XHTML pages can be read by all XML enabled devices AND while waiting for the rest of the world to upgrade to XML supported browsers, XHTML gives you the opportunity to write “well-formed” documents now, that work in all browsers and that are backward browser compatible
等到世界上的其它浏览器都升级为⽀持XML的时候,XHTML能够被所有⽀持XML的设备读取,现在XHTML给你⼀个写出“合格”⽂档的机会,使这些⽂档能够在所有的浏览器中查看,并且有良好的向后兼容性。
XHTML 与 HTML之间的区别
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 < /p >.
另外,现在你应该开始⽤⼩写字母来书写你的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中⼀些元素可以不使⽤正确的相互嵌套像这样:
[coolcode]This text is bold and italic[/coolcode]
In XHTML all elements must be properly nested within each other like this:
在XHTML所有元素必须合理的相互嵌套像这样:
[coolcode]This text is bold and italic[/coolcode]
Note: A common mistake in nested lists, is to forget that the inside list must be within a li element, lik
e this:注意:在列表嵌套的时候经常会犯⼀个错误,就是忘记了在列表中插⼊的新列表必须在⼀个< li >标记中,像这样:[coolcode]
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.
在这段正确的代码⽰例中,要注意在
之后加了⼀个
标签
[/coolcode]
Documents Must Be Well-formed
⽂档格式必须合格
All XHTML elements must be nested within the < html > 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标记必须被嵌套使⽤在< html > 根标签之中。所有其他的标签可以有⾃⼰的⼦标签。位于⽗标签之内的⼦标签也必须成对且正确的嵌套使⽤。⼀个⽹页的基本结构是:
[coolcode] …
[/coolcode]
Tag Names Must Be In Lower Case
标签名称必须是⼩写
This is because XHTML documents are XML applications. XML is case-sensitive. Tags like < br > and
are interpreted as different tags.
这是因为XHTML⽂档是XML应⽤程序,XML是区分⼤⼩写的,像
会被认为是两种不同的标签。
This is wrong:
这是错误的:
[coolcode]
This is a paragraph
[/coolcode]
This is correct:
这是正确的:
[coolcode]
This is a paragraph
[/coolcode]
All XHTML Elements Must Be Closed
所有的XHTML元素必须关闭
Non-empty elements must have an end tag.
⾮空元素必须有关闭标签。
This is wrong:
这是错误的:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。