tags:

views:

45

answers:

5
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<style type="text/css">
.Footer{
background-color:red;
width:673px;
height:1px;
}
</style>

<title>Second</title>
</head>

<body>
<div class="Footer"></div>
</body>
</html>

if i remove <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; from the coding.. <div> height is not support i wand 2 work with out <!DOCTYPE>

+1  A: 

You can't work without doctype, it is integral part of the HTML document.

Edit:

*it is integral part of the valid HTML document.

rochal
No! It's an optional element that specifies the rules for the markup language (DTD)
balexandre
-1 and I agree with balexandre. The doctype is an addition to an XML document and in the future it will become obsolete due to XML Schema.
Alin Purcaru
agreed - you **can** work without a doctype, but you'd be mad to not use a valid one, at least for now
Ross
check my edit..
rochal
HTML is not XHTML and the HTML specifications say that the Doctype is mandatory.
David Dorward
+1  A: 

If you want empty divs, you need a doctype otherwise most browsers will ignore the height.

Workarounds: Use a doctype or insert something in the div.

Edit:

Actually, you need the XHTML doctype for empty divs to work.

Maxem
+2  A: 

Hi,

When you don't add a doctype to your document the browser considers that HTML page as being from the period before doctypes were introduced so it renders in quirks mode and the rules are different (way different).

Hopefully some day we will no longer see those doctypes but for now you have to use them to distinguish from ancient HTML documents.

Alin Purcaru
A: 

This mistake it's nothing about <doctype> but the way height: 1px; is interpreted by the browser.

just add overflow: hidden; and all will be fine even without a <doctype>

balexandre
A: 

Not adding a Doctype isn't particular wrong but it will cause some browsers to Render your page quite unpredictable, and i can't think of any good Reason not to add a Doctype, if the XHTML Doctype is to complex for you, just add the HTML5 Doctype: <!DOCTYPE html>

Hannes