Why do we need doctype in HTML/JSP pages? Pages seem to work without it.
Escpecially Microsoft IE has a major problem with certain doctypes or a complete lack of doctype. At the bottom of this page you can find a concise overview of browser behaviour in combination with certain doctypes. There are three standard behaviours:
width
and height
then incorrectly covers the padding
and border
.Here's a piece of HTML which demonstrates the box model bug in IE. Copy'n'paste'n'run it. With <!DOCTYPE html>
present, you'll see a rectangle. Without the doctype line you'll see a genuine square.
<!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>
The influence of this IE bug is the most noticeable when you want a "pixelperfect" webdesign.
Zeldman wrote
Per HTML and XHTML standards, a DOCTYPE (short for “document type declaration”) informs the validator which version of (X)HTML you’re using, and must appear at the very top of every web page. DOCTYPEs are a key component of compliant web pages: your markup and CSS won’t validate without them.
and Take a look at 24 Ways Article "Transitional vs. Strict Markup"
at coming HTML 5 , you'll only need to declare
<!DOCTYPE HTML>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With