DOCTYPE

The doctype declaration should be the very first thing in an HTML document, before the <html> tag. The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version of the markup language the page is written in. The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers can render the content correctly.

 

DOCTYPE 元素语法
HTML顶级元素 可用性 "注册//组织//类型 标签//定义 语言""URL"

例如:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22>

语法元素说明
顶级元素:指定 DTD 中声明的顶级元素类型。这与声明的 SGML 文档类型相对应。 默认为HTML。

可用性:指定正式公开标识符(FPI)是可公开访问的对象还是系统资源。取值可以为PUBLIC或者SYSTEM.PUBLIC 默认。表示可公开访问的对象。SYSTEM表示系统资源,如本地文件或 URL。

注册:指定组织是否由国际标准化组织(ISO)注册。

+为默认,表示组织名称已注册。

-表示组织名称未注册。Internet 工程任务组(IETF)和万维网协会(W3C)并非注册的 ISO 组织。

组织:指定表明负责由 !DOCTYPE 声明引用的 DTD 的创建和维护的团体或组织的名称,即 OwnderID。 IETF为IETF。W3C为W3C。

类型:指定公开文本类,即所引用的对象类型。 默认为DTD。

标签:指定公开文本描述,即对所引用的公开文本的唯一描述性名称。后面可附带版本号。默认为HTML。

定义:指定文档类型定义。

  1. Frameset 框架集文档。
  2. Strict 排除所有 W3C 专家希望逐步淘汰的代表性属性和元素,因为样式表已经很完善了。
  3. Transitional 包含除 frameSet 元素的全部内容。

语言:指定公开文本语言,即用于创建所引用对象的自然语言编码系统。该语言定义已编写为 ISO 639 语言代码(大写两个字母)。 EN 默认。英语。

URL:指定所引用对象的位置。

 

HTML 4.01 Strict

This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed.

HTML 4.01 Transitional

This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed.

HTML 4.01 Frameset

This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content.

Elements that are not allowed in Strict DOCTYPEs
  • center
  • font
  • iframe
  • strike
  • u
Attributes not allowed in Strict DOCTYPEs
  • align (allowed on elements related to tables: col, colgroup, tbody, td, tfoot, th, thead, and tr)
  • language
  • background
  • bgcolor
  • border (allowed on table)
  • height (allowed on img and object)
  • hspace
  • name (allowed in HTML 4.01 Strict, not allowed on form and img in XHTML 1.0 Strict)
  • noshade
  • nowrap
  • target
  • text, link, vlink, and alink
  • vspace
  • width (allowed on img, object, table, col, and colgroup)

虽然如此规定,但是各个浏览器厂商并没有严格执行。比如上面的background,虽说在Strict时不支持,但是在Firefox3.6.8和IE9中依然可以照常使用。

http://www.w3schools.com/tags/tag_DOCTYPE.asp

http://msdn.microsoft.com/en-us/library/ms535242(VS.85).aspx

原文地址:https://www.cnblogs.com/whyandinside/p/1808442.html