Hi,
It does not appear to have anything to do with z-index in this case.
Rather it looks like IE6/7 do not place the div’s BG color underneath the dotted border like other browsers do.
You can see what is going on by setting a red BG color on the body and commenting out the negative top margin on the lower div.
yes it is true that ‘IE6/7 do not place the div’s BG color underneath the dotted border like other browsers do’ - what a pain with fit in IE! :injured:
Which doesn’t say. CSS2 added a lot of clarifications that contradicted what IE had already done by building off the draft version of the spec… Which is why we’re still dealing with this mess of inconsistency. (and why I still say CSS3 shouldn’t be used on production pages)
The background of an element is the area covered by the width and height of that element (whether those dimensions are set explicitly, or the content dictates them); it also includes the area covered by padding and borders. A background-color (or background-image) that’s applied to an element will appear beneath the foreground content of that element, and the area covered by the padding and border properties for the element. This coverage area is evident where an element has transparent (or dotted or dashed) borders, and the background is seen beneath the borders (or between the dots). Note that Internet Explorer versions up to and including 6 don’t support transparent borders.
IE7 and under though have haslayout issues here:
Internet Explorer for Windows versions up to and including 7 will only apply the background from inside the border’s edge when the element in question has a layout. If the element does not have a layout, the background-color or background-image will slide under the borders as per the specifications.
Regarding the tiling of the background image then this is also covered in the specs and in the reference as the initial background position is 0,0 which is defined at the edge of the padding box (which means rather awkwardly that the initial position is inside the border but the image will eventually be repeated into that area if background-repeat is set.
If no background-position has been specified, the image is placed at the default top-left position of the element (0,0), which is located within the top-left corner of the element, just inside the border at the outside edge of the padding box.
Whether that is a sensible approach is another matter as an image will be repeated into the area under say dotted or transparent borders and will look very bad (In those cases a negative background-position should be used to start the image in line with the border).
Fun part of this one is that like many thing, neither way of doing it is incorrect; see – the specification doesn’t actually say where the background should go in relation to the border.
IE’s way actually makes MORE sense – background should be on the element inside the border, since border is supposed to be around the element not on it. If anything, the behavior of putting the background under it is more akin to the ‘quirks mode’ broken box model in behavior.
I do agree with you Jason, IE7 seems to make more sense and give us what we would expect here.
Obviously this only happens when there is a dotted or dashed border. On top of that all browsers render the pattern differently too.
With 10px dotted borders on all fours:
FF gives us some cutesy little hearts (mitered dots) in the corner
IE gives a single dot starting in the corner (as I would expect)
Opera gives square dots, starting in the corner like IE
Webkit gives square dots mitered in the corner like FF
Similar results with dashed borders but FF makes a mess of them, it appears to layout the border in a clockwise order without averaging the gap before it turns the corner.
EDIT: Those results are only based on the dimensions I used below, they are subject to change with different dimensions and border sizes.