html<! The role of the doctype> statement

Source: Internet
Author: User

What's the use of this line of code in an HTML page?

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">


In a page refactoring process, see the static page of the first line there is a piece of code, followed by a large blank, in the deletion of the blank when the code accidentally deleted the line, and then ....

The original display normal page, an instant messy, font style has not, the key is placed in IE browser next look, layout is completely misplaced,,,, also thought is the style in addition to the problem, found a half-day also did not find the reason, fortunately, the original file has a backup, took out a comparison, on this line of code in doing strange, What the hell does it do?

<! The doctype>  declaration is positioned at the front of the document, before the  

doctype function  
doctype statement indicates what rule sets the reader should use to interpret the markup in the document. In the case of a Web document, a "reader" is usually a program such as a browser or a validator, and "rules" are the rules contained in a document type definition (DTD) published by the website. &NBSP,
Each DTD includes a series of tags, attributes, and properties that mark the contents of a Web document, as well as 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. &NBSP,
If the markup in the document does not follow the DTD specified by the DOCTYPE declaration, this document may not be displayed correctly in the browser, except in the case of code validation. The browser is more tolerant than the validator for problems with markup inconsistencies. However, incorrect DOCTYPE declarations often cause web pages to appear incorrectly or cause them to not display at all.



html<! The role of the doctype> statement

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.