Why do we need DOCTYPE on HTML / JSP pages?

Why do we need doctype in HTML / JSP pages? Pages seem to work without it.

+5
source share
6 answers

Zeldman wrote

In accordance with the HTML and XHTML standards, DOCTYPE (short for "document type declaration") informs the validator which version of (X) HTML you are using, and should appear at the very top of every web page. DOCTYPE is the key component of compatible web pages: your markup and CSS will not be validated without them.

and take a look at Article 24 of the Transitional vs. Articles Strict markup "

HTML 5

<!DOCTYPE HTML>
+8

, Microsoft IE doctype. . :

  • Q - Quirksmode. . IE. CSS width height padding border.
  • A - . , CSS2. , .
  • S - . w3 HTML/CSS. , , , - .

HTML, IE. "". <!DOCTYPE html> . doctype .

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Remove DOCTYPE to trigger quirksmode</title>
        <style>
            #box { 
                background: yellow; 
                width: 100px;
                padding: 20px; 
                border: 20px solid black; 
                margin: 20px;
            }
        </style>
    </head>
    <body>
        <div id="box">box</div>
    </body>
</html>

IE , - "pixelperfect".

+8

. http://www.quirksmode.org/css/quirksmode.html ; , doctype quirks/ .

, , , , .

+1

, html- DOCTYPE, html , html .

0

DOCTYPE , , .

, IE quirks, .

See this link for Remember to declare your doctype .

0
source

doctype is a browser instruction about the markup language version. doctype enables the html attribute.

0
source

All Articles