Learning Web Standards: DOCTYPE (document Type) basics

Source: Internet
Author: User
Tags version
Web|web Standard | Web page DOCTYPE (document type) DOCTYPE is a shorthand for document type, which is used to indicate what version of XHTML or HTML you are using.

What are they and why are they important?
All HTML and XHTML documents must have a valid DOCTYPE declaration.

DOCTYPE specify the version of HTML or XHTML that the document uses.

When the checksum is used by the DOCTYPE, the Web browser determines which rendering mode is used.

DOCTYPE affects how your device renders Web pages.

If the document uses the correct DOCTYPE, some browsers will switch to standard mode, which means the browser will adhere to more CSS rules.

If the document uses the correct DOCTYPE, the document will render faster because the browser does not take the time to think about how to render HTML correctly.
The main types of DOCTYPE
HTML 4.01 Strict


In the above declaration, the root element of the document is declared HTML, which is defined in a DTD with a public identifier of "-//w3c//dtd HTML 4.01//en". The browser will see how to find a DTD that matches this common identifier. If it is not found, the browser uses the URL following the public identifier as the location to look for the DTD.

HTML 4.01 Transitional


HTML 4.01 Frameset


XHTML 1.0 Strict


XHTML 1.0 Transitional


XHTML 1.0 Frameset


XHTML 1.1


Standards compliant (or strict) and quirks modes
Most browsers have two modes: the weird mode (quirks mode uses the old rules) and the strict mode (strict mode adheres to the standard). Mozilla, Safari, Opera, Mac/explorer, Windows/explorer 6 implement both modes. Windows/explorer 5 and old browsers like Netscape 4 are performing weird patterns.

There are some very important reasons for using strict mode (strict mode or adherence to standard patterns). For example, Windows/explorer 6 will use the correct box model (box mode) when using strict mode, and the wrong box model will be executed when using quirks mode. In addition, under quirks mode, some modern browsers will not allow fonts to be inherited.

Do you need an XML declaration?
The consortium recommends the use of XML declarations in XHTML documents, but it is not necessary to do so. So it depends on the developer to decide. If you have this declaration, WINDOWS/IE6 will ignore any used DOCTYPE and execute quirks mode. The XML declaration looks as follows:


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.