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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    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

  • Andy Dingley

    #2
    Re: Padding and Margin. Could someone, please, help me out? Thank You.


    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"

    Comment

    • Ben C

      #3
      Re: Padding and Margin. Could someone, please, help me out? Thank You.

      On 2006-12-07, shapper <mdmoura@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.

      Comment

      Working...