468,771 Members | 1,859 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

Padding and Margin. Could someone, please, help me out? Thank You.

Hello,

I created a div with margin and padding and a fixed width.
It seems the behavior is different in Firefox and IE.

I am not sure but it seems:
True width = width + paddingORmargin
OR
True width = width

Could someone, please, clarify this for me?

Thanks,
Miguel

Dec 7 '06 #1
2 1755

shapper wrote:
It seems the behavior is different in Firefox and IE.
Find a good CSS website ( www.brainjar.com
www.positioniseverything.com ) and read up on "quirks mode" and "box
model"

Dec 7 '06 #2
On 2006-12-07, shapper <md*****@gmail.comwrote:
Hello,

I created a div with margin and padding and a fixed width.
It seems the behavior is different in Firefox and IE.

I am not sure but it seems:
True width = width + paddingORmargin
When you say "true width" you mean the width measured from outside the
margin area? In that case, this is the conforming interpretation.
OR
True width = width
I think some versions of IE do that if you don't use strict mode. In
other words, when you set width you're setting the width you'd like the
box to be outside its margin and padding.

Always use strict mode, just put

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

very first thing in each HTML document.
Could someone, please, clarify this for me?
But... for table cells and tables the "width" property sets the outer
width, even in strict mode in Firefox.

I suspect this comes down to a difference between the HTML and CSS
specs. The HTML spec says that the "width" attribute on a table means
"the desired width of the entire table".

The width attribute is usually mapped directly to the CSS width
property. In other words:

<table width=400>

is equivalent to

<table style="width: 400px">

in the former case, 400 should refer to the "entire width", but in the
latter case, to be consistent with the fact that in CSS a table is
supposed to behave mostly like a block box, 400px should refer to the
inside-padding width.

So browsers have a problem: either break the simplicity of the mapping
between the HTML width attribute and the CSS width property, or treat
CSS widths differently for tables. They mostly do the latter.
Dec 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by delerious | last post: by
36 posts views Thread by phil-news-nospam | last post: by
10 posts views Thread by Alan Silver | last post: by
11 posts views Thread by sllrphoto | last post: by
reply views Thread by adminloozer | last post: by
11 posts views Thread by maya | last post: by
8 posts views Thread by rodeored | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.