Niclas: padding: bug oder feature

Beitrag lesen

Hallo,

beim Versuch, eine Seite nur mit CSS zu layouten, bin ich auf eine etwas lästige css-interpretation von Netscape und MSIE gestoßen (getestet unter OSX: netscape 7 und ie 5.1). --- falls diese nachricht eine dublette ist, bitte ich um entschuldigung.

folgender code produziert in IE zwei gleich große boxen, in netscape nicht:

----schnipp----

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>boxtester</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

<style type="text/css">
<!--
body {background-color:#ffffff; color:#000000; }
.box1 { height:100px; width:100px; padding:0px; border:solid 1px #000000; }
.box2 { height:100px; width:100px; padding:10px; border:solid 1px #000000; }
-->
</style>

</head>

<body>
The Two Boxes:
<div class="box1">box1</div><div class="box2">box2</div>
</body>
</html>
----schnipp----

in netscape ist die angezeigte breite des divs width+padding, msie hält sich strikt an die width-vorgabe. indes ist das verhalten von netscape offenbar kein bug:

----schnipp----

http://www.w3.org/TR/REC-CSS1#block-level-elements

4.1    Block-level elements
[...]
The width of an element is the width of the content, i.e., the distance between left inner edge and right inner edge. The height is the height of the content, i.e., the distance from inner top to inner bottom.

----schnipp----

bug oder feature: wer mit css layouten will, sollte auf padding wohl besser verzichten und versuchen, das gleiche ziel mit margin zu erreichen.

Gruesse,
niclas