任何不开始使用HTML 5文档的理由? [英] Any reason not to start using the HTML 5 doctype?

查看:94
本文介绍了任何不开始使用HTML 5文档的理由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它应该向后兼容HTML4和XHTML。 John Resig发布了一些好处



只要我们不使用任何新的和不受支持的功能,是否有任何缺点开始用这个文档类型来构建网站?

>解决方案

请考虑这一点:



当用作text / html时,您需要一个doctype来触发标准模式。除此之外,就浏览器而言,doctype不做任何事情。



当作为text / html使用时,无论您使用XHTML标记还是HTML标记,它都被浏览器视为所以,真正归结为使用触发标准模式(<!DOCTYPE html>)的最短文档类型和使用HTML标记来产生正确结果的标准模式(<!DOCTYPE html)浏览器。

其余的内容是关于符合性,验证和标记优先。

!DOCTYPE html>现在,只要你坚持现在在浏览器中运行的稳定功能,试图使你的标记符合HTML5并不是一个坏主意。您不会在HTML4或XHTML 1.x中使用任何在浏览器中不起作用的东西,您会吗?



换句话说,您使用<!DOCTYPE html> ;与HTML4类似的标记,同时表彰已在HTML5中阐明的事物。毕竟,HTML5与浏览器兼容。



现在使用HTML5的缺点是规格可能会经常更改。这对于您在规范发生积极变化时遵循规范非常重要。 http://validator.nu/ 可能并不总是最新的,但 http://validator.w3.org/ 并不总是最新的,所以不要让它停止当然,如果你想使用XHTML 1.0标记并符合XHTML 1.0,那么你不应该使用<!DOCTYPE html>。

>

就我个人而言,我总是使用<!DOCTYPE html>为HTML。


It is supposed to be backwards compatible with HTML4 and XHTML. John Resig posted about some of the benefits.

As long as we don't use any of the new and not supported yet features, would there be any downside to start building sites with this doctype?

解决方案

Well consider this:

When serving as text/html, all you need a doctype for is to trigger standards mode. Beyond that, the doctype does nothing as far as browsers are concerned.

When serving as text/html, whether you use XHTML markup or HTML markup, it's treated by browsers as HTML.

So, really it comes down to using the shortest doctype that triggers standards mode (<!DOCTYPE html>) and using HTML markup that produces the correct result in browsers.

The rest is about conforming, validation and markup prerference.

With that said, using <!DOCTYPE html> now and trying to make your markup conform to HTML5 is not a bad idea as long as you stick to stable features that work in browsers now. You wouldn't use anything in HTML4 or XHTML 1.x that doesn't work in browsers, would you?

In other words, you use <!DOCTYPE html> with HTML4-like markup while honoring things that have been clarified in HTML5. HTML5 is about browser compatibility after all.

The downside to using HTML5 now is that the spec can change quite often. This makes it important for you to keep up with the spec as it actively changes. Also http://validator.nu/ might not always be up-to-date, but http://validator.w3.org/ isn't always up-to-date either, so don't let that stop you.

Of course, if you want to use XHTML 1.0 markup and conform to XHTML 1.0, then you shouldn't use <!DOCTYPE html>.

Personally, I always use <!DOCTYPE html> for HTML.

这篇关于任何不开始使用HTML 5文档的理由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆