Search code examples
htmlinternet-explorer-8stylesheet

Why wont this display in IE8?


    <div style="width:180px; height:18px; border-bottom:1px solid #666; position:relative; z-index:500; margin-left:10px;">
        <div style="float:left; width:70px; height:18px; position:absolute; left:0; top:0; z-index:1; background-color:white; ">KEY</div>
        <div style="float:right; height:18px; position:absolute; right:0; top:0; z-index:1; background-color:white; ">VALUE</div>
    </div>

Renders perfectly in Chrome, Firefox, Safari, etc. But in IE8 it doesn't work.


Solution

  • IE8 is a jerk with relative positioning if the renderer doesn't detect the doctype properly. Try specifying:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "w3.org/TR/html4/loose.dtd">