This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Stylesheets > December 2003 > Collapsing margins rule





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Collapsing margins rule
Spartanicus

2003-12-23, 1:29 pm

I've been caught out by what I thought was an Opera 7.5p1 issue:
http://www.spartanicus.utvinternet....image_issue.htm

but as was pointed out to me this is actually a fault in my code which
is exposed by the improved CSS standards support in v7.5p1.

The top margin on the <h1> collapses with the zero margin on the <body>
element to form a single margin equal to the margin specified on the
<h1>.

I predict that this improved behaviour will catch out more people as the
collapsing vertical margin rule is probably not sufficiently understood
by quite a few of us. I've encountered this issue before, but Opera 7.5
is the first browser to implement the collapsing vertical margin rule
correctly with respect to the <body> element.

A good understanding of the box model is helpful in solving potential
problems. In the example given above the problem can be solved by
specifying a 1px padding on the <body> element, the rule for collapsing
margins then no longer applies since the padding exists between the
margin on the <body> element and the top margin on the <h1>.

Btw, Opera 7.5p1 is the first browser to display 2 of my older sites
(coded strictly to the standards with no regard for browser quirks)
without any issues, quite a feat.

--
Spartanicus
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews