Closed Bug 299938 Opened 19 years ago Closed 19 years ago

padding-top: 0px doesn't work with div

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
minor

Tracking

()

RESOLVED INVALID

People

(Reporter: antti.jokipii, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

Following page doesn't show padding-top: 0px; correctly.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Padding error</title>
	<style>
	body {
		padding: 0px;
		margin: 0px;
		background-color: #000000;
	}
	#all {
		padding-top: 0px;
		background-color: #ffffff;
	}
	#content {
		background-color: #ff0000;
		margin-left: 200px;
	}
	</style>
</head>
<body>
	<div id="all">
		<div id="content"><p>content</p></div>
	</div>
</body>
</html>

Any other value for padding-top works correctly. Changing padding-top to padding
doesn't sovle problem. Putting content inside #all div fixes problem, example
&nbsp; works.

Reproducible: Always
I think you're experiencing the margin collapsing effect here, see for example
http://www.andybudd.com/archives/2003/11/no_margin_for_error/ for more info.
Preventing margins of collapsing can be done for example by adding border:1px
solid transparent to #all.
(In reply to comment #1)
Yes. It is the margin collapsing effect.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.