Fix Margins in IE6 with jQuery

by Thomas Beutel

IE6’s well known margin problems can be solved many ways, such as using CSS that only IE6 will read.

I like to use CSS and jQuery as follows:

CSS:

#wrapper
 {
  margin: 0 auto;
  width: 800px;
  ...
 }
 .wrapperie6
 {
  width: 810px !important; /* compensate for IE6 */
 }

and the jQuery code:

$(document).ready(function() {
  if($.browser.version == '6.0'){
  // alert('you are using ie6');
  $('#wrapper').addClass('wrapperie6');
  }

It’s rude and crude, but it does the job.