我们应该使用哪种DOCTYPE声明? [英] Which DOCTYPE declaration should we use?

查看:135
本文介绍了我们应该使用哪种DOCTYPE声明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读了许多关于DOCTYPE声明和三种版本的书籍:严格的,过渡性的和框架式的。



但我仍然无法完全理解它们的区别实际上我不确定在创建我的网站时应该使用哪种变体。特别是我不明白严格和过渡之间的区别。



你能否给我建议?

解决方案

Frameset适用于定义框架集的文档(非框架集文档随后会加载到框架中)。框架通常是一个糟糕的设计选择,它会导致更多的问题,然后他们解决。

过渡性或多或少是严格加上你不应该使用的东西(主要是因为它们有已被CSS取代)。有一些例外情况,例如 start 属性,它有一些很好的参数来支持使用它(但不是常常有用)。

严格是HTML的核心,通常是最好的选择。

HTML 4.01是最新的,已完成版本的HTML。



XHTML 1.0是以XML表示的HTML 4.01。它在Internet Explorer中不起作用,除非您假装它是HTML(text / html规范允许)。
$ b XHTML 1.1是XHTML 1.0 Strict加上target属性再加上Ruby(不是编程语言)以及其他一些小调整。



(五年前:HTML 5是一个草案规范,可能会发生变化,并且许多有趣的功能在没有JavaScript的情况下无法在现在使用的大多数浏览器中进行备份。它缺少成熟的验证工具。

HTML 4.01通常是最好的选择,但XHTML 1.0是值得考虑,如果你的发布系统中有一个XML工具链,并且HTML 5值得考虑,如果你需要添加一些东西,并觉得生活在流血边缘的风险是值得的。

总之:使用HTML 4.01 Strict,除非你知道为什么你需要使用别的东西。)



由于这个答案最初是用HTML编写的,HTML 5已经成为具有良好浏览器和工具链支持的标准。这是与浏览器实际工作方式最接近的规范。如果您需要XML支持,则可以使用XML序列化。



简而言之:使用HTML 5:<!DOCTYPE html>


I have read a number of books on DOCTYPE declaration and the three variations: strict, transitional and frameset.

But I am still not able to fully understand their difference and indeed am not sure which variation I should use when creating my website. In particular I don't understand the difference between strict and transitional.

could you please advise me?

解决方案

Frameset is for documents that define framesets (non-frameset documents are then loaded into the frames). Frames are usually a poor design choice that cause more problems then they solve.

Transitional is, more or less, Strict plus things you shouldn't use (mostly because they have been replaced with CSS). There are a couple of exceptions, such as the start attribute which has some good arguments to support using it (but isn't often useful).

Strict is the core of HTML and is usually the best bet.

HTML 4.01 is the latest, finished version of HTML.

XHTML 1.0 is HTML 4.01 expressed in XML. It doesn't work in Internet Explorer unless you pretend it is HTML (which the text/html specification does allow).

XHTML 1.1 is XHTML 1.0 Strict plus the target attribute plus Ruby (not the programming language) plus a few other minor tweaks. There is no specification giving the OK to pretend XHTML 1.1 is HTML.

(Five years ago: HTML 5 is a draft specification, subject to change, and with many of the interesting bits not working without JavaScript backing them up in most browsers in use today. It lacks a mature validation tool.

HTML 4.01 is generally the best bet, but XHTML 1.0 is worth considering if you have an XML toolchain in your publishing system, and HTML 5 is worth considering if you have a need for something added in it and feel the risk of living on the bleeding edge is worth it.

In short: Use HTML 4.01 Strict unless you know why you need to use something else.)

Since this answer was originally written, HTML 5 has become a standard with good browser and toolchain support. It is the specification most closely aligned with how browsers actually work. An XML serialisation is available if you need XML support.

In short: Use HTML 5: <!DOCTYPE html>.

这篇关于我们应该使用哪种DOCTYPE声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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