CSS padding Firefox vs IE

This is a discussion on "CSS padding Firefox vs IE" within the Web Page Design section. This forum, and the thread "CSS padding Firefox vs IE are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 17th, 2007, 21:15
New Member
Join Date: Oct 2007
Location: Canada
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Layout Difference (Firefox vs IE)

ARRG! So I recently (about a week) started learning/using CSS to build a website. You might remember my thread not too long ago about how to make a modular setup. Thank you so much to the people that responded to that thread. It solved that problem. However, I'm having some other beginner issues because firefox and IE seems to interpret padding differently.

If i made a division class of width:200px; margin-left:20px; border-left:10px; padding-left:5px;, then I would assume the <div> would take the space of 230px with active text room of 170px.

This is assuming the following:

width - defines the outside edge of borders

border - width is added INTO the width space so DOES NOT expand overall division width.

margin - width is added OUTSIDE the boarder and width space so this DOES expand overall division width.

padding - width is added INTO the border so DOES NOT expand overall division width.

Are the above assumptions correct?
It seems my testing with Firefox and IE are producing different results as if they interpret these properties differently.

Is it true that these things are interpreted differently? If so, how so? From what I've tested, it seems padding for Firefox seems to expand the overall width. How do I layout the page so that these differences between firefox and IE would not be so?

Right now, I'm thinking, to get around the padding issue, I would nest two divisions using "margins" only because it seems margins are interpreted the same for both Firefox and IE. This is an option for me because I don't need a background image. However, I thirst for a more elegant way of processing this difference.

Last edited by WL1207; Oct 18th, 2007 at 02:16.
Reply With Quote

  #2 (permalink)  
Old Oct 17th, 2007, 22:36
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,769
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: CSS padding Firefox vs IE

Very easy fix that should work!
at the top of your stylesheet put:

Code: Select all
* {margin: 0px; padding: 0px;}
This tells all browsers not to add any padding or margins unless you tell it to!
* is the universal selector which applies to everything.

Good luck.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #3 (permalink)  
Old Oct 17th, 2007, 22:51
New Member
Join Date: Oct 2007
Location: Canada
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS padding Firefox vs IE

Yes, at the top of the page I do put that. The problem is, I actually need some margins/padding so when i specify them in the specific uses, it screws up. Is there a better way of margins/padding then?
Reply With Quote
  #4 (permalink)  
Old Oct 17th, 2007, 23:11
New Member
Join Date: Oct 2007
Location: Canada
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS padding Firefox vs IE

Okay, so I also discovered that "borders" are also handled differently between IE and Firefox.

I made a few examples to show my frustration. I made the boarders wide (40px on each side) to illustrate it easier:

The CSS embedded html files are here:
http://www.ece.ualberta.ca/~wliu/css/

Each one is also followed by a screen cap of how differently they look in Firefox vs IE. So here is a description:

(Note: I basically want a width of 770px of usable space all the way down the page.)

example1:
division width: 770, border: 40 on each side.
banner pic width: 770

Top Banner: Both Firefox and IE does what I want.
Content: Firefox does what I want, but IE seems to somehow clip the available space for the "pink" division by 40+40 = 80px.


example2
division width: 770+40+40 = 850, border: 40 on each side.
banner pic width: 770

Add on the 80 pixels to width and Firefox expands overall width by 80px as expected. However, IE does not expand overall width at all.
Top Banner: Now firefox top banner is 80px too wide for the banner photo, but IE is doing what I want.
Content: Now in Firefox, the "pink" box is wider by 80px which is cosmetically okay. IE is now doing what I want in this bottom content section. The pink section's width is regained to the correct width.


example3
division width: 855, border: 40 on each side.
banner pic width: 770

Add another 5px to width for kicks to see what happens.
The two browsers now react similarly to the change. The background for the top banner is another 5px bigger while banner photo remains the same. The bottom "pink" content is not pushed inwards and is expanded by another 5px.



Please, please, please, can anyone help figure out what's going on and what I should do such that I get what I want in BOTH browsers.... I've been frustrated with this since yesterday afternoon!

- Weiyang
Reply With Quote
  #5 (permalink)  
Old Oct 18th, 2007, 09:45
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: CSS padding Firefox vs IE

Is you code hosted anywhere so we can see what is going on. Sometimes it's easier to SEE what the problem is instead of reading what the problem is
Reply With Quote
  #6 (permalink)  
Old Oct 18th, 2007, 13:56
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: CSS padding Firefox vs IE

Ok ... for one ... don't use the * fix ... It's better to define the padding and margin to each element by doing

Code: Select all
html, body, ul {
    margin: 0;
    padding: 0;
}
Next ... yes Ie and FF interprets the box-model differently. When you set a width in you CSS and have margins, padding and borders, FF will count that in the total width of your div as oppose to IE6 that doesn't.

Thus referring to the Box Model Hack

However, it is now better to define the different width using IE conditional comments like this

HTML: Select all
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->

hth
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Padding In IE Monie Web Page Design 7 Feb 12th, 2008 03:36
Firefox ignoring padding-left rawling Web Page Design 9 Jul 11th, 2007 22:03
ie padding problem adsalamon Web Page Design 1 Dec 29th, 2006 16:31
Padding on #header background image.. IE6/Firefox. rooraaahcrumbs Web Page Design 1 Apr 26th, 2006 20:49
Disappearing padding in IE diagonalArgument Web Page Design 1 Jan 8th, 2006 14:03


All times are GMT. The time now is 03:59.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43