DOCTYPE detailed description

Source: Internet
Author: User
Tags object definition contains key version
The DOCTYPE statement follows certain rules that indicate what set of rules the reader should use to interpret the markup in the document.

DOCTYPE not scary, but take it away, will make you scared and afraid.

Recently in the blue ideal around, found a lot of friends to ask about div+css typesetting issues, and IE and FF compatibility issues. There are all the questions, and the result is one--it's very strange and difficult to adjust. Most of the sites we browse, or create a new Web document with Dreamweaver, the top of the source code will have DOCTYPE statements, but many people do not pay attention to it, even in the creation of the time to delete it directly, in fact, this is often the beginning of nightmares. DOCTYPE is a required element in any Web document that adheres to the standard. It affects code validation and determines how the browser ultimately displays your Web document. To avoid recurring problems with DOCTYPE, I have compiled this document for my own and interested friends, based on the information at hand.

By default, the interpretation criteria for FF and IE are different, that is, if a Web page does not declare DOCTYPE, it interprets the following HTML with the default DOCTYPE. Under the same standard, different browser models have differences in interpretation, if the declaration criteria are different, do not need me to say, you can do it yourself. Learn Web standards, browser compatibility, where to start your own decision, however, please know DOCTYPE:

One, what is DOCTYPE

DOCTYPE is a shorthand for document type, which is used in a page to specify the XHTML (or HTML) version used by the page. An essential key component of a standard-compliant page is the DOCTYPE declaration. Only the identification of a correct doctype,xhtml and CSS in order to take effect normally.

Ii. rules of the DOCTYPE

The DOCTYPE statement follows certain rules that indicate what set of rules the reader should use to interpret the markup in the document. In the case of Web documents, "reading programs" is usually a program such as a browser or a validator, and "rules" are rules that are contained in a document type definition (DTD) published by the Consortium.
Each DTD includes tags, attributes, properties, and so on to mark the contents of the Web document, and also includes rules that specify which tags can appear in other tags. Each Web recommendation standard (such as HTML 4 frameset and XHTML 1.0 Transitional) has its own DTD.

Here are the rules to extract from the manual:

Grammar:

HTML top-level element Availability "register//organization/Type label//Definition language" URL "

Possible values:

-top-level element: Specifies the top-level element type declared in the DTD. This corresponds to the declared SGML document type. HTML default. Html.
-Availability: Specifies whether the official public identifier (FPI) is a publicly accessible object or a system resource. public defaults. An object that can be publicly accessed. system resources, such as local files or URLs.
-Registration: Specifies whether the organization is registered by the International Organization for Standardization (ISO). + Default. The organization name is registered.
-The organization name is not registered. The Internet Engineering Task Force (IETF) and the World Wide Web Consortium (WWW) are not registered ISO organizations.
Organization: Designated to indicate responsibility by! The name of the group or organization that DOCTYPE declares the creation and maintenance of a referenced DTD, that is, Ownderid. IETF IETF. The consortium is a consortium.
-type: Specifies the exposed text class, which is the referenced object type. DTD defaults. Dtd.
-Tags: Specifies the public text description, that is, the unique descriptive name of the exposed text that is referenced. The version number can be attached later. HTML default. Html.
-Definition: Specifies the document type definition.
The Frameset frameset document.
Strict excludes all the representative properties and elements that the consortium wants to phase out, because the stylesheet is already perfect.
Transitional contains everything except the frameSet element.
-language: Specifies the public text language, the natural language encoding system that is used to create the referenced object. The language definition has been written as an ISO 639 language code (uppercase two letters). EN default. English.
-URL: Specifies the location of the referenced object

In order to get the correct DOCTYPE declaration, the key is to have the DTD correspond to the standards followed by the document. For example, assuming that the document follows the XHTML 1.0 Strict standard, the DOCTYPE declaration of the document should refer to the appropriate DTD. On the other hand, if the DOCTYPE declaration specifies an XHTML DTD, but the document contains a legacy-style HTML tag, it is inappropriate; Similarly, if the DOCTYPE declaration specifies an HTML DTD, but the document contains an XHTML 1.0 strict tag, is equally inappropriate.

Third, choose what kind of doctype

As shown in the example above, there are 3 types of DTD (document type definition) declarations in XHTML 1.0 that can be selected: Transition (transitional), Strict (Strict), and Framework (Frameset). Here is a description of each of the following.

1. Transition of

A less stringent DTD that allows the HTML4.01 identity to be used in the page (conforming to the XHTML syntax standard). The transition DTD is written as follows:

"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

2. of strict

A strict DTD that does not allow the identification and attributes of any presentation layer, such as
, to be used. The strict DTD is written as follows:

"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >

3. of the framework

A DTD used specifically for frames pages that are used when a page contains a FRAME element. The framework's DTD is written as follows:

"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" >

Using a strict DTD to make a page is, of course, the ideal way. However, for web designers who do not have an in-depth understanding of web standards, it is more appropriate to use a transition DTD. Because the DTD also allows for the identification, elements, and attributes of the presentation layer, it is more appropriate for most web page makers.

Iv. issues to be noted

Nothing special, just be sure to put the DOCTYPE declaration at the top of the XHTML document, even if there are not many HTML annotation tags.

The best example code also adds DOCTYPE, otherwise the effect is different.



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.