Jump to content

Margin 12px for IE7 + Firefox, but need 6px for IE6?


scooter41

Recommended Posts

I am just in the process of designing a layout, and have come across an element that lines up perfectly with a margin of 12px on IE 7 and Firefox, yet is way off in IE6, and needs a margin of 6px for IE6 ... I always thought pixels would be rendered the same across browsers but obviously not!

 

I know its possible to do with a javascript browser detection, and then perhaps writing some JS to call another stylesheet or write it inline, but is there anyway more elegant that could perhaps be written in the CSS

 

If browser is IE6,

 

margin-left:6px

 

else

 

margin-left:12px

 

 

that sort of thing?

 

Thanks for any help in advance

 

Scott

Link to comment
Share on other sites

IE6 has a "double margin bug". For example:

 

#myelement1 {float:left; margin-left:10px;}
#myelement2 {float:right; margin-right:10px;}

 

Both examples will result in a doubling of the margin in IE6 because you've got a margin on the same side as the direction that the element is floated.

 

It is easy to fix by adding {display:inline;} to your code for the element that is experiencing the problem.

 

All other browsers will ignore the declaration because a floated element is always displayed as a block (even in IE6 when you use this declaration). However, it is probably best to put this into a conditional stylesheet targeting only IE6 in order to properly separate all the IE-specific pieces of code from the code that is purely standards orientated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.