user2331566
user2331566

Reputation:

IE 8 won't display width 100%

I have a very simple code http://jsfiddle.net/MuYVs/ '

    <style type="text/css">

        #header-cont {
            width:100%;
            background:#0080c9;
            background-color:#0080c9;
            height:50px;
            position:absolute;
            top:0px;
            left: 0px;
        }

    </style>
<head>
<body>
    <div id="header-cont"></div>    
</body>'

This is fine in Chrome, however, in IE8 the bar will go 98% across and with a little gap at the end. How on earth do I tell IE8 to stop being so silly?

Upvotes: 0

Views: 78

Answers (3)

Fabio S
Fabio S

Reputation: 1122

Add the doctype at the beginning:

<!DOCTYPE html>

Upvotes: 1

rabz100
rabz100

Reputation: 751

Try removing any default padding and margins from the body element.

body {
    margin: 0;
    padding: 0;
}

Upvotes: 1

LiamB
LiamB

Reputation: 18586

This looks like default settings the browser has implemented. Have a look at a reset style sheet

http://meyerweb.com/eric/tools/css/reset/

Upvotes: 1

Related Questions