HTML Document Declaration

Source: Internet
Author: User

Previous words

?? HTML documents typically begin with a type declaration that will help the browser determine the type of HTML document it is trying to parse and display. This article describes the document declaration in more detail DOCTYPE

Characteristics

?? The document declaration must be the first line of the HTML document, and shelf display, insensitive to case. Because anything placed in front of DOCTYPE, such as annotations or XML declarations, will trigger a weird pattern in IE9 or earlier browsers (which is described later in the rendering mode)

?? Because the document type declaration is not a label, you should not have a close label

Version
version year
Html 1991
html+ 1993
HTML 2.0 1995
HTML 3.2 1996
HTML 4.01 1999
XHTML 1.0 2000
HTML5 2014

Statement

HTML5

<!DOCTYPE html>

?? Before HTML5, there are three types of document declarations: strict strict, transitional transitional, frame frameset

HTML4.01

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> 

XHTML1.0

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

XHTML1.1 equivalent to XHTML1.0 Strict

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">    

"DTD"

?? A DTD, called a document type definition, defines a legitimate XML document building block that uses a series of legitimate elements to define the structure of a document. In HTML, the DTD uses XML to define the HTML tag specification

?? Because HTML5 is not SGML-based, you do not need to reference DTDs. However, DOCTYPE is required to enable the standard mode (which is described later in the rendering mode). The syntax elements of HTML5 come from SGML, HTML, XHTML1. X, making it a synthetic language with its own rules.

?? The relationships between HTML, XML, and SGML are not easily distinguishable. HTML is an example of SGML, and its DTD is fixed as a standard, so HTML cannot be used as a meta-language for defining other labeling languages. XML is a subset of SGML, and strictly speaking, XML is also SGML. Unlike HTML, XML has a DTD, which can also be used as a meta-language as SGML, to define other file systems or to place slogans. If the label language is divided into meta-slogan and instance-labeling language, SGML and XML are meta-labeling languages, and HTML and XML-derived XHTML are instance-labeling languages

?? [note] For more information about DTDs.

Rendering mode

?? On a long-ago network, pages typically have two versions: the version prepared for Netscape (Netscape) and the version prepared for Microsoft Internet Explorer (navigator). When the network standard was created, the browser could not directly employ these standards in order not to destroy the existing websites. As a result, browsers use two modes to separate websites and older sites that meet the new specifications.

?? There are three modes of the browser typesetting engine: The Quirks mode, the close to standard mode (almost standards mode), and the standard (standards mode). In weird mode, typography simulates Navigator4 and Internet Explorer 5 's nonstandard behavior. This is necessary to support Web sites that have been built before network standards are widely adopted. In standard mode, behavior is the behavior that is described by the HTML and CSS specifications. In the approach to standard mode, only a few weird behaviors are implemented

?? For HTML documents, the browser uses the DOCTYPE at the beginning of the document to decide whether to handle it in weird mode or Standard mode. If there is no DOCTYPE in the document, it will trigger the strange pattern of the document. The most obvious effect of the weird pattern is that it triggers the weird box model. In CSS, the box model is divided into two types, the first is the standard model, and the second is the weird box model. The difference is that the width and height of the weird box model defines the dimensions of the visible element frame, not the content area size of the element box.

HTML Document Declaration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.