padding in divs - with mozilla

A

Adi Schwarz

Hi,

Is it known that mozilla has problems with aboslute widths in divs?

I reduced that error to a very simple page:


<html>
<body>

<div style="width:50px; background-color: blue; padding:5px">nl</div>

<table style="width:50px; background-color: green; padding: 0px"
border="0" cellspacing=0 cellpadding=0><tr><td>asd</td>

</tr></table>
</body>
</html>


Mozilla seems to mistake padding with margin in that context - the div's
width is 60px in this context (the DOM-Inspector calculates the right
CSS-definitions, but in the "box-model" it says 60px width to this box).
This does not occur if padding is set to 0px.

My IE5 has no problems with that situation, but I have been told that
some IEs make similar errors when there is some content in the div.

Had anyone else that strange problem?

Greets,
-adi
 
T

Toby A Inkster

Adi said:
<div style="width:50px; background-color: blue; padding:5px">nl</div>

Mozilla seems to mistake padding with margin in that context - the div's
width is 60px in this context

My IE5 has no problems with that situation,

IE5 gets it wrong and instead it SUBTRACTS the padding from inside the
50px blue box, giving the content ("nl") only 40px of space. This
particular IE bug is fixed in IE6 (and IE5 for Mac)

For more information on this matter (called the CSS "box model") see:

http://www.w3.org/TR/CSS21/box.html#box-dimensions

There is a similar explanation in the CSS1 spec, but I think the CSS2
explanation is a little clearer, with a better diagramme.
 
D

David Dorward

Toby said:
Adi Schwarz wrote:

The blue box created by the <div> *should* be 60px in this case. Padding
is ADDED ON to the width when drawing the box.

^ to the content width
IE5 gets it wrong and instead it SUBTRACTS the padding from inside the
50px blue box, giving the content ("nl") only 40px of space. This
particular IE bug is fixed in IE6 (and IE5 for Mac)

IE, except version 6 when in standards mode, treats width as "width between
vertical borders", the specification says "width of content".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top