Thursday, April 13, 2006

Fieldset Border Bug in IE

There are many problems with the way that fieldsets are rendered across virtually all browsers. This is yet another for the IE pile, and it only happens in obscure circumstances, so I'm not too surprised I haven't seen it posted elsewhere.

If you apply a negative margin to the top or bottom of an input or select element in a fieldset that has a legend, the top border of the fieldset will be repeated at the position of each input or select element. Sound a little murky? Check out the test page.

The test page has a strict doctype, but the bug also occurs with transitional doctypes. I've confirmed the bug in IE 5, IE 5.5, and IE 6. Let me know if you have a workaround!

Was this post helpful to you? If so, please consider making a small donation to keep this blog going.

6 Comments:

Blogger tom said...

Related info may be found
here.

6:58 AM  
Anonymous Anonymous said...

I had the exact same problem, thanks to your post, I've been able to fing out that negative margin-top on one of my elements was the reason.

The error does not occur, hovewer, if you use border-bottom (or left/right) - only top border gets repeated.

Unfortunately, i couldn't find any workaround and had to simulate top border with a background image.

8:16 AM  
Anonymous Anonymous said...

Ditto; I also had to make a fake top border with a background image.

11:56 AM  
Blogger keif said...

I end up doing (having hit your site from google) is to have a background color on the form, and a nested fieldset with a bg color of white.

Yes, it's kind of cheating, but it degrades nicely and plays well with all browsers.

12:18 PM  
Anonymous Anonymous said...

Instead of using the background-image to simulate a border to your fieldset, try to set a top border the color of ur form background( if possible in your design)

fieldset{
border: 0 solid #fff;
border-bottom: 1px solid red;
}

It had a pixel but if you can afford it. :D

12:24 PM  
Anonymous Anonymous said...

Thank you for posting this! I just want to add that it also happens in IE7 on windows. My "work around" was just to change all the css so I wasn't using negative margins inside a fieldset.

3:21 AM  

Post a Comment

<< Home