What is <! DOCTYPE html>, as well as its importance

What is <! DOCTYPE html>?

At the beginning of the HTML document, there will always be such a sentence <! DOCTYPE html>, then its meaning, what is it? It is html5 standard page statement, called Document Type HyperText Mark-up Language, meaning the document type for the hypertext markup language, or HyperText Markup Language, is now the concise form, support html5 standard mainstream browsers know this statement. It represents the pages using html5, <! DOCTYPE> declaration is located in front of the location in the document, before the <html> tag in. This tag tells the browser which HTML or XHTML specification documentation use.
This tag can declare three kinds DTD type, respectively strict version, as well as interim version of HTML-based documentation framework.
This line declares a public document root element is html, it is defined as a public identifier "- // the W3C // DTD XHTML 1.0 
Strict // EN" is defined in the DTD. The browser will know how to find this common identifier matching DTD. If not, the browser will use the URL to find the back of the public identifier as DTD location.

<! DOCTYPE html> importance?

1 action: The resolution of type (document.compatMode) a statement of the document, to avoid browser quirks mode.

  document.compatMode:
BackCompat: quirks mode, the browser uses its own quirks mode rendering parsing the page.
CSS1Compat: standard mode, the browser uses the W3C standard analytical rendering the page.
 

       This property will be to identify and use the browser, but if your page does not DOCTYPE declaration, then compatMode default is BackCompat,

Browser in its own way resolve to render the page, it will show different styles in different browsers.

    If you add a page <! DOCTYPE html> So, it is equivalent to the standard mode is turned on, the browser must honestly in accordance with the W3C

Standard analytical rendering the page, this way, your page displayed in the browser on all is a way of.

This is the <! DOCTYPE html> role.

2 Use: <DOCTYPE html!>

2.1 is also very simple, that is the first line of your html page add "<! DOCTYPE html>" line of code on it

2.2 jsp then added <% @ page%> of the next row.

2.3 not case sensitive

 

Attachment: caveats

Nothing special, is sure to xHTML Doctype statement at the top of the document, even more than the above html comment tags will not work.

 

The best example code also add Doctype, otherwise the effect will vary. Although we do not give sentence statement browser HTML document will still be revealed, but due to bug HTML version may cause lies here.

 

 

 

This article is reproduced from the original bad boy blogger Code URL: https: //www.cnblogs.com/Eton/p/6063450.html

Guess you like

Origin www.cnblogs.com/HDWdemo/p/12005120.html