Forum Moderators: not2easy

Message Too Old, No Replies

Padding. Wrong dimensions.

Problems with padding in IE.

         

LetItBe

11:59 am on May 26, 2006 (gmt 0)

10+ Year Member



Hi there,

Check the simple code which I use for <div></div> tags:

.head {
width: 100px;
height: 100px;
padding: 10px 10px 10px 10px;
}

In FF the width of this div is exactly 100px, but in IE - 120px. Any solutions how to make width 100px in both browsers?

Thanks.

LetItBe

5:27 pm on May 26, 2006 (gmt 0)

10+ Year Member



No ideas? :/

bachya

5:32 pm on May 26, 2006 (gmt 0)

10+ Year Member



I'm not sure what you're asking...that should make a 100px X 100px box that's padded on all sides by 10px (which, I suppose, would create a box of 120px around).

Could you clarify a little?

LetItBe

5:37 pm on May 26, 2006 (gmt 0)

10+ Year Member



You see the code of css file.

<div class="head"></div>

This is the code of html file.

I open this html file in FireFox. View is ok - div's width is 100 pixels. Then I open it in Internet Explorer. View is wrong - div's width is 120 pixels. Why?!

jessejump

6:38 pm on May 26, 2006 (gmt 0)

10+ Year Member



Put this at the top of your document

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

LetItBe

7:17 pm on May 26, 2006 (gmt 0)

10+ Year Member



Nah, it still doesn't work, jessejump. :(

LetItBe

7:28 pm on May 26, 2006 (gmt 0)

10+ Year Member



Don't trouble. I found it out by myself.

Thanks.

bedlam

7:31 pm on May 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, this seems pretty clearly to be a box model [google.com] problem--though the symptom you describe is precisely opposite of the usual case (i.e. in quirks mode you would normally expect IE to display the div at the specified width regardless of padding).

The fix--and sorry, but without code it's impossible to be more specific than to say 'read this stuff'--is to ensure that both browsers render the page in standards mode instead of quirks mode [google.com]. Usually this can be achieved just by adding a complete doctype [google.com] to your documents as jessejump has already suggested, but there may be other factors at work causing IE to render in quirks mode even if a proper doctype is present.

Start by running your pages through the html [validator.w3.org] and css [jigsaw.w3.org] validators and correcting the problems they flag.

-b

GoWFB_SEO

5:35 pm on May 30, 2006 (gmt 0)

10+ Year Member



well, in that case
use html>.head for whatever you already did, and that will work for FF

then redeisgn a one that is
.head{
variable
}

to make it work for IE

If you have further questions, let me know