Why is it when I have a DOCTYPE line in my HTML then "margin" and
"padding" are ignored?
This happens in both inline and stylesheet styles.
It happens for both XHTML and HTML doctypes.
It happens in IE6, IE7 and Firefox (didn't try any others).
And when you save the page, the margin/paddings are actually REMOVED
from the saved HTML file (!).
Why is this?
Here you can see the problem:
And here there is no DOCTYPE line and so the page is fine:
Here is my HTML (Valid XHTML 1.0 Strict):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Exampl e of DOCTYPE / inline margin issue</title>
<link href="xhtmlMarg inIssue.css" type="text/css" rel="stylesheet "/>
</head>
<body>
<p>Because I have a DOCTYPE on this page, the <b>margin</band
<b>padding</bstyles are ignored. Why?<br/>
<a href="xhtmlMarg inIssueWithoutD octype.htm">If I take the DOCTYPE
line out then it works.</a></p>
<div style="margin: 20 20 20 20;background-color:#ddd;font-size:
24pt;color:red; padding: 100 100 100 100">inside inline-css div </div>
<p>First sentence outside the divs. </p>
<div class="message" >inside stylesheet-css div</div>
<p>Second sentence outside the divs.</p>
</body>
</html>
"padding" are ignored?
This happens in both inline and stylesheet styles.
It happens for both XHTML and HTML doctypes.
It happens in IE6, IE7 and Firefox (didn't try any others).
And when you save the page, the margin/paddings are actually REMOVED
from the saved HTML file (!).
Why is this?
Here you can see the problem:
And here there is no DOCTYPE line and so the page is fine:
Here is my HTML (Valid XHTML 1.0 Strict):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Exampl e of DOCTYPE / inline margin issue</title>
<link href="xhtmlMarg inIssue.css" type="text/css" rel="stylesheet "/>
</head>
<body>
<p>Because I have a DOCTYPE on this page, the <b>margin</band
<b>padding</bstyles are ignored. Why?<br/>
<a href="xhtmlMarg inIssueWithoutD octype.htm">If I take the DOCTYPE
line out then it works.</a></p>
<div style="margin: 20 20 20 20;background-color:#ddd;font-size:
24pt;color:red; padding: 100 100 100 100">inside inline-css div </div>
<p>First sentence outside the divs. </p>
<div class="message" >inside stylesheet-css div</div>
<p>Second sentence outside the divs.</p>
</body>
</html>
Comment