Document Type Declaration 文档类型声明

The document type declaration (DTD) <!doctype html> is used to specify which language and code version the document is using so that an internet browser can render (display) the website correctly. The document type declaration does not represent an HTML element; however it is an important prerequisite for all HTML documents.

文档类型声明(DTD)<!doctype html>用于指定文档使用的语言和代码版本,以便网页浏览器能够正确呈现(显示)网站。文档类型声明不是HTML元素,但它是所有HTML文档的重要先决条件。

Since the document type declaration does not represent an HTML element it is not actually a document tag; however the term “tag” is a generally used term that tends to be applied generically across the web. Therefore describing document types as a document tag is generally accepted even though this description is technically incorrect. The general document type declaration is <!doctype html>.

由于文档类型声明不表示HTML元素,因此它实际上不是文档标记;然而,术语“标签”是一个普遍使用的术语,它倾向于在整个网络中普遍应用。因此,将文档类型描述为文档标记通常是可以接受的,即使这种描述在技术上是不正确的。一般文档类型声明为<!doctype html>。

Below is a list of several older DOCTYPE declarations下面是几个较旧的DOCTYPE声明的列表: 

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 3.2//EN”>

<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>

Syntax语法:

The Document Type Declaration is written as <!doctype> with the specified language being inserted within the declaration. 

文档类型声明写为<!doctype>,在声明中插入指定语言。

The <!doctype> declaration must be at the top of the page, before any other HTML code and is case sensitive. Since the document type declaration is not a tag there is no end tag required for document type declarations.

<!doctype> 声明必须位于页面顶部,在任何其他HTML代码之前,并且区分大小写。由于文档类型声明不是标签,因此文档类型声明不需要结束标签。

Example例: 

pastedGraphic.png
Instructions: Retype this code in an HTML editor and then load the webpage in a browser of your choice. Then once you have loaded the page try experimenting with the code. Making a few small changes and then preview how those changes affected your webpage. Once you are comfortable with this HTML Tag you should proceed to the next example.

Proceed to the next example: HTML Tag