<! DOCTYPE html> is important.

Source: Internet
Author: User

The beginning of the nightmare: before writing HTML or JSP page, never pay attention to DOCTYPE statement, also do not understand the role of DOCTYPE. Until recently encountered a very wonderful bug: A page in IE7 and 8,chrome,ff and so on, but in the IE9 under the problem, I began to look for, all kinds of debugging, all kinds of log, finally found in HttpWatch inside the answer:DOCTYPE not declared . So I added <! to the page. DOCTYPE Html>, and sure enough it worked.

Here I will be as concise as possible to explain the role and use of DOCTYPE.

1 function: Declare the parsing type of the document (Document.compatmode), avoid the strange mode of the browser.

Document.compatmode:
Backcompat: Weird mode, the browser uses its own weird mode to parse the rendered page.
Css1compat: Standard mode, browser uses the standard resolution rendering page.

This property will be recognized and used by the browser, but if your page does not have a DOCTYPE declaration, then compatmode defaults to Backcompat,

This is the beginning of the demon--the browser parses the rendered page in its own way, and the different styles are displayed in different browsers.

If you add <! to your page DOCTYPE html> So, then it is equivalent to open the standard mode, then the browser will have to honestly follow the

The standard parsing renders the page, so that your page will appear in all browsers in one way.

This is <!. The role of DOCTYPE html>.

2 Use: <! DOCTYPE html>

2.1 Easy to use is to add "<!" in the first line of your HTML page DOCTYPE html> "One line of code is OK.

2.2 JSP, add the next line in <%@ page%>.

2.3 Do not use case-sensitive!

Quote Original: http://angrycoder.iteye.com/blog/1757539

<! DOCTYPE html> is important.

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.