Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Div widths in IE and FF 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
Simple example of my problem is where I have a div with a background image and padding set to 5px.
As FF adds the padding size to the overall size of the div it displays ok in IE but FF repeats part of the image.
How do I handle the div height and width so that they display correctly in both FF and IE?


Keith
 
You add a complete and valid doctype as the very first thing in your html file. This way IE (versions 6 and above) use the correct box model -- just like the one Firefox uses.

Valid doctypes can be found here:
___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Thanks, I knew there had to be a simple solution. I had the doctype but I had added a place holder before it, in the form of a comment. I thought that the browser would ignore it but it appears not. I remember clearing up this issue before but I cannot find any of my relevant notes.

IE and FF apper to handle <p>....</p> constructs in a different way. IE inserts a larger horizontal space than FF. is there an accepted way to straighten this out?

Keith
 
Default paddings and margins differ across the browser. The only way to do is to specify your own margins and padding. An easy way to avoid all the trouble is to put this at the top of the css stylesheet:
Code:
* {
  padding: 0;
  margin: 0;
}
As for the doctype. Comments should be ignored and all the browsers ignore it. Except for IE.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Are there any other elements which render differently in the various browsers? I am thinking along the lines of set a default value for all elements at the start of a stylesheet to ensure a level playing field.

Keith
 
There are quite a few reset stylesheets out there. Try Eric Meyer's Resetting Again
or search for another one that meets your needs.

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top