views:

21

answers:

2

My HTML+CSS graphic

My issue with this page is that the "High School", "Middle School", and "Elementary School" images center perfectly in all browsers except for IE6, 7, and 8.

Relevant parts of the page: (Edited for clarity)

CSS:

#block {
    clear: both;
    width: 682px;
}
.education_level_wrapper {
    float: left; 
    width: 100%;
}
.education_level {
    margin-bottom: 3px;
    margin-left: auto;
    margin-right: auto;
    display: block;
}

HTML:

<div id="block">
    <div class="education_level_wrapper">
        <img src="[sniped]/Title_HS.png" class="education_level" />
    </div>
</div>

IE:

alt text

Chrome:

alt text

What am I doing wrong here?

EDIT:

See the fixed version here: Non-Archived Graphic. The above link was a snapshot to stay consistent for archival purposes.

+1  A: 

Prepend your page with <!DOCTYPE HTML> to get browsers to attempt to comply with the CSS spec.

Right now you're letting browsers render those pages as if this was 2001.

Technical explanation is that, in IE6 quirks mode auto margin wont work without being in standards mode. The workaround if you HAVE to use quirks mode is to apply text-align:center on the parent element. But you should be using standards mode, aka sane mode.

meder
Wow, that was simple... Thanks!
Josh Patton
A: 

The attribute float: left in education_level_wrapper function is the probable cause of this problem.

Use margin to adjust positioning rather than

float

Dora
The float attribute was required due to the layout. If you look at `.education_level` you'll see that I attempted to use `margin`. IE standards mode was the issue, see accepted answer.
Josh Patton