On 27 Sep 2007, at 14:40, Mark Story wrote:

> Nick Fitzsimons wrote:
>> On 27 Sep 2007, at 14:04, Scott Povlot wrote:
>>> If I don't have a border, what is the difference
>>> between using padding or margin to add space around an
>>> element? Is there any reason to choose one over the
>>> other?
>> Vertical margins collapse; padding doesn't:
>> <http://www.w3.org/TR/CSS21/box.html#collapsing-margins>
>>
> However, vertical margins do not collapse in IE6 (are you  
> surprised) so
> the big difference when using padding and margin is that margins will
> collapse most of the time.  Also if you are applying any sort of
> background, the background will spill into the padding but not the
> margin of an element.
>
> -Mark

Actually, IE6 _does_ support collapsing margins, but gets it wrong  
(are you surprised :-) in a number of cases, such as when an element  
hasLayout and also has child nodes with margins which should collapse  
with the margins of preceding or following boxes (they don't).

Another difference between margin and padding: margins can have  
negative size; padding can't.

Cheers,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/

______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to