Getting Fieldset Backgrounds and Legends to Behave in IE

I’m sure someone has posted on this issue before I just haven’t found an answer I’m looking for. Jeff Croft has a close answer, but he is trying to solve a different problem. I built off of his exploration for this solution.

The “problem” occurs when you are building a form with a fieldset tag and a legend tag, and then style the fieldset with a background color like so:

HTML

    
User Information CSS fieldset{ background: #ccc; }

Proper rendering (in every browser but IE is close to this: (this specific screenshot is from Firefox)

Correct Rendering of Form

IE does something a little different: it causes the background color to be applied to the legend as well, mysteriously causing the background color to “spill” out of the fieldset.

Default Rendering in IE

The solution is to dissociate the legend tag from the normal flow of the document. That is, absolutely position it. Here’s how: (Since IE is the only browser that needs help with this, we are going to use the Holly Hack, so it only applies to IE)

1. Give the fieldset a position: relative; to make sure we are positioning the legend tag relative to the fieldset.

    * html fieldset{
    position: relative;
    }

2. Give the legend a position: absolute; to break it out of the normal flow of the fieldset. This will position the top left corner of the legend with the top left corner of the fieldset, so we need to bump it up half a character and to the right half a character. Like so:

    * html legend{
    position:absolute;
    top: -.5em;
    left: .5em;
    }

3. Now we’re almost there. By way of a little cleanup, we are going to apply some top padding to the fieldset and a top margin to the fieldset in order to make space for the label tag which is just floating on top of everything.

    * html fieldset{
    position: relative;
    margin-top:1em;
    padding-top:.75em;
    }

4. Voila! You have a form with a fieldset and a legend that looks nearly identical in all browsers.

Fixed form in IE

See an example here.


Posted

in

by

Comments

161 responses to “Getting Fieldset Backgrounds and Legends to Behave in IE”

  1. Yannick Avatar

    Hey Matt,

    Thanks! I have had that problem with a few projects, but didn't know how to solve it so invariably I would have to scrap using a background colour. Now at least I know how to get it to work right.

  2. Nando Vieira Avatar

    Great tip! Thanks a lot!

    1. asdfasdf Avatar
      asdfasdf

      asdfsdaf

    2. asdfasdf Avatar
      asdfasdf

      asdfsdaf

    3. asdfasdf Avatar
      asdfasdf

      asdfsdaf

    4. asdfasdf Avatar
      asdfasdf

      asdfsdaf

    5. asdfasdf Avatar
      asdfasdf

      asdfsdaf

    6. asdfasdf Avatar
      asdfasdf

      asdfsdaf

    7. asdfasdf Avatar
      asdfasdf

      asdfsdaf

    8. asdfasdf Avatar
      asdfasdf

      asdfsdaf

    9. asdfasdf Avatar
      asdfasdf

      asdfsdaf

    10. asdfasdf Avatar
      asdfasdf

      asdfsdaf

    11. asdfasdf Avatar
      asdfasdf

      asdfsdaf

  3. […] Matt Heerema : Web Design » Getting Fieldset Backgrounds and Legends to Behave in IE (tags: css design html fieldset) […]

  4. […] Matt Heerema has some useful tips for the “problem” that occurs when you are building a form with a fieldset tag and a legend tag, and then style the fieldset with a background color which ends up spilling outside of the fieldset. What to know how to fix it for IE? Head over and see what to do. […]

  5. Mike P. Avatar

    Hi, thanks for the great fix!!! I was wondering if you could give some additional advice. I'm nesting Fieldset and Legend and when I do so the Fieldset text overlaps when I implement this fix unless I do a line break in the XHTML. It's probably a simple margin fix, but I can't seem to figure it out. I don't want to use the because it creates too much room in FIrefox/Mozilla, etc.

    I've published a couple screens to show you what I'm running into. http://www.wvdhhr.org/bcf/temp_ieBugonFieldset.ht

    Thanks again for the tip and for any advice you may give.

  6. […] The main problem with events like CSS Reboot, et al, are that they serve as sort of a Total Perspective Vortex for me. It reminds me how far I have to go, and how much I have to learn. What keeps me from giving up is that I feel I have something to contribute to the noise. I just have to find my niche (solutions to strange CSS problems perhaps?) and write about it, constantly. […]

  7. Jamie Avatar
    Jamie

    Another fix for this problem is to have a background image for the fieldset, 1 pixel wide and much taller than the fieldset will be. Does mean you have to change the image to change the colour though…

    Something along the lines of:

    • html fieldset {

      background: url(/img/backgrounds/fieldset.gif) repeat-x top;

    }

    fieldset

    {

    background: url(/img/backgrounds/fieldset.gif) repeat-x bottom;
    
    margin-bottom: 2em;
    
    border: #000066 solid 1px;
    
    padding: 1em;
    
    padding-top: 0.4em;
    

    }

  8. Chris Owens Avatar

    This doesn't seem to work correctly in the current IE7 Beta.

  9. Gordon Avatar
    Gordon

    Actually the method does work in IE7. The Holly Hack however doesn't. The method works fine if you put the above in a seperate stylesheet and load it with a conditional comment.

  10. Matt Avatar

    Thanks, Gordon, for pointing that out. I have not had much time to play with IE7. Should probably get on that.

  11. Kim Siever Avatar

    "Viola!"

    Personally, I prefer the violin. :)

  12. Matt Avatar

    Oh dear.

    So, my ignorance is showing. Isn't it "víola", a french word pronounced "Walla!"?

    Or am I way off.

  13. […] Getting Fieldset Backgrounds and Legends to Behave in IE – Matt Heerema : Web Design (tags: css xhtml webdesign fieldset ie hack) […]

  14. audrey Avatar
    audrey

    voila – you have the i & o transposed.

  15. Matt Avatar

    HA… ya that. oops.

  16. Milosz Avatar

    OK. Solution is great but I have to insert 3 fieldsets one under one and now I have big trouble how to apply more or less the same margin between fieldsets in IE and Firefox.

    Ane ideas?

    Thanks.

  17. Rhodus Avatar
    Rhodus

    Opera seems to put the inside the when doing this…

  18. […] I was working on some CSS for a form and realized that applying a background to the fieldset didn’t really have the desired effect. The background flows out at the top of the fieldset in IE (what a surprise!). Luckily, I found a solution to the problem on Matt Heerema’s blog. Works like a charm! […]

  19. Wild & Wacky Avatar
    Wild & Wacky

    I think that this answers my prayers – but, after playing around, I think it is missing something!!

    What I want/need is a box around the 'tab heading'. And for the whole of this new box to have a coloured background (like the 'main' box.

    Anyone know the cure?

    Please!!!

  20. […] As most of you know, I have some kind of shoulder problem. I started seeing a physio November last year about it and have been having treatment since. A few weeks ago I hurt it at Kung Fu, and have been going easy since. Little did I know I had re-wrecked it. Its again out of commission for a month, so no swinging punches. Which is basically what Choy Lay Fut is all about. So ill have to think of something. Lucky for me, Bando has the thumbs up, due to its striking being very tight quick movements. So today, we did sparring. And I seem to be having trouble walking. Now its not every day I get hammered…. actually… I seem to get hurt a lot now I think about it… Hmmm… where was i going with this again…. oh yeah, I tend to not bruise very easily at all. If I do usually get them, they aer usually a few days later and kind of light. However… I got home no more than 3 hours ago and my shins are already getting darker. Good times. I seem to have a slight one appearing on my upper thigh after getting knocked on my ass by Mr Kroll. My only rehab at the moment is after any training, I have to ice the shoulder for ~10 mins. And it gets cold…. DAMN cold…. Anyway, on a less violent note, im starting to prepare for IE7. Not really getting excited, more reading up on how I will have to have the bastard to display CSS properly.. I have been doing a few more Accessible forms as of late and had just found a fix for fieldset background spillage in IE. From what I have read so far in preliminary preports and whatnot all hacks should work, and CSS should render better than before. Of course, this poses a problem. Do we change doing CSS to incorporate the fixes in this version, or would you still allow for IE6 users, making any updates completely irrelevant? Hmmm… I shalll ponder the conundrum over a bottle of water… Also, the Jets are on tomorrow at the Inglewood. Im quite tempted to go… Actually, im quite sure I will. […]

  21. ant Avatar
    ant

    Thanks, I've been looking for something like this for years!

    One thing, I noticed the background still sticks out the top a bit. You can fix that by doing "legend { margin-top: -[width of fieldset border] }"

  22. lotek Avatar

    fieldset the same in FireFox IE7 Opera

    This code is use in PHP but you can do the same in javascript :p

    <code>

    fieldset {

    position: relative;
    
        border: 1px solid #090;
    
    margin: none;
    
    padding: 0px 10px 10px;
    
    background: #eee;
    
    -moz-border-radius: 10px;
    

    }

    legend {

    top: -0.5em;
    
    margin-left: 10px;
    
    padding: 0px 10px;
    
    background: #9cf;
    
    font-weight : bold;
    
        border: 1px solid #090;
    
        -moz-border-radius: 10px;
    

    }

    </code>

  23. lotek Avatar

    the website clean my php code …

    fieldset the same in FireFox IE7 Opera

    This code is use in PHP but you can do the same in javascript :p

    <code>

    fieldset {

    position: relative;
    
        border: 1px solid #090;
    
    margin: none;
    
    padding: 0px 10px 10px;
    
    background: #eee;
    
    -moz-border-radius: 10px;
    

    }

    legend {

    top: -0.5em;
    
    margin-left: 10px;
    
    padding: 0px 10px;
    
    background: #9cf;
    
    font-weight : bold;
    
        border: 1px solid #090;
    
        -moz-border-radius: 10px;
    

    }

    </code>

  24. lotek Avatar

    fieldset the same in FireFox IE7 Opera

    This code is use in PHP but you can do the same in javascript :p

    <code>

    fieldset {

    position: relative;
    
        border: 1px solid #090;
    
    margin: none;
    
    padding: 0px 10px 10px;
    
    background: #eee;
    
    -moz-border-radius: 10px;
    

    }

    legend {

    (?php if( !eregi( 'opera', $_SERVER[ 'HTTP_USER_AGENT' ])) echo 'position: relative;'; ?)

    top: -0.5em;
    
    margin-left: 10px;
    
    padding: 0px 10px;
    
    background: #9cf;
    
    font-weight : bold;
    
        border: 1px solid #090;
    
        -moz-border-radius: 10px;
    

    }

    </code>

  25. […] Getting Fieldset Backgrounds and Legends to Behave in IE – Matt Heerema : Web Design (tags: css webdesign) […]

  26. Dustin Brewer Avatar

    For the person asking about multiple fields. I ran into the same trouble. Messing with the margins wasn't getting me anywhere. I noticed someone said a br tag worked, but created too much space in FF/Opera. Well, if you use conditional comments it works beautifully.

    Hopefully this comes through correctly (remove the spaces).

  27. jonah Avatar
    jonah

    … still doesn't work in IE7

  28. jonah carneskog Avatar
    jonah carneskog

    I got it to work in IE7 by adding a margin-top:-5px; on the legend.

    My stylesheet now looks like this.

    fieldset {

    position: relative;

    border: 1px solid #fff;

    padding: 0px 10px 10px;

    background: url(../images/semi.png);

    width:870px;

    margin: 20px auto;

    }

    legend{

    margin-top:-5px;

    top: -0.5em;

    margin-left: 10px;

    padding: 0px 10px;

    background: #000;

    font-weight : bold;

    border: 1px solid #fff;

    -moz-border-radius: 10px;

    }

    Works like a charm in FF and IE7.

  29. Mike Dowson Avatar
    Mike Dowson

    this method seems to work in ff2 and ie7, although problems do occur if the user resizes the window.

    form fieldset legend {

    background-color: #820027;

    padding: 8px;

    color:#FFFFFF;

    position: relative;

    top: -20px;

    display: block;

    margin-left: 0px;

    margin-right: -8px;

    margin-top: 5px;

    }

    form fieldset {

    border: 1px solid #820027;
    
    background-color: #EFECE2;
    

    }

  30. […] mattheerema.com – Yet another interesting Blog entry I stumbled onto when researching HTML I think. This entry covers some interesting issues and behaviors of using the legend command in html on Internet Explorer. […]

  31. […] Zitat von Despairing 2. In meinem Gästebuch wird im Internet Explorer-Browser jedes Fieldset fehlerhaft dargestellt. Die Hintergrundfarbe des Fieldsets wird ein paar Pixel über der Fieldsetbox dargestellt, was nicht so sein sollte. Wie kann ich das unterbinden? Hatte ich letzhin gerade auch. Lösung siehe Getting Fieldset Backgrounds and Legends to Behave in IE – Matt Heerema : Web Design __________________ The only thing to do with good advice is pass it on. It is never any use to oneself. – Oscar Wilde – #me { position: absolute; } […]

  32. ekashkash Avatar
    ekashkash

    Awsome.. It worked perfectly.

    Thank you very much!

  33. Frank Topel Avatar

    I got it to work in both IE 6 and 7. Problem remains, that IE shows the legend text in blue color, even though I have

    legend {

    color: #666;

    }

    in my css.

    Any ideas?

    P.S.:

    fieldset {

    color: #666;

    }

    and

    body {

    color: #666;

    }

    are also set.

  34. Frank Topel Avatar

    The above problem occurs only in IE 7 Final.

  35. Maxim Micheliov Avatar

    Thanks for a brilliant solution. Me too found that this method applied "as it is" doesn't bring the desired result in IE7. However there seem to be another way around the problem – to put the above css rules (by Matt Heerema)into an IE condition comment.

    <!–[if IE]>–>

    fieldset { position:relative }

    legend {

    position:relative;

    top:-0.7em; margin-bottom:-0.7em;

    }

    Usually I have such CSS pocket to store all the IE specific hacks in one place. Why not to drop there the discussed rules?

  36. Maxim Micheliov Avatar

    Ups the form didn't let me put the complete code…

    fieldset { position:relative }

    legend {

    position:relative;

    top:-0.7em; margin-bottom:-0.7em;

    }

  37. Maxim Micheliov Avatar

    My sorry to a moderator, just want to share a bit of wisdom. Please fit it somehow into the comments if think it is useful.

    The rules can be placed inside if IE condition statement.

  38. Jon Avatar

    thanks for this! it worked perfectly!

  39. sandro Avatar

    Thanks for the fix, came straight from google and was happy to find simple well formed code with clear instructions. Perfect!

  40. Quinti Avatar

    Buahs

    thank u very much for this post, i'm trying aaaaall the css things to change the color legend in IE,

    f….. IE!!! i hate it!

    greetingss

  41. SalsaShark Avatar
    SalsaShark

    Found one problem with this method. In Safari, it draws the border all the way around the fieldset. Legend text is placed above the border, but still a bit of a problem.

  42. Paul Avatar

    Thanks to all! I was pulling my hair out to get this to work.

  43. vivian hua Avatar

    thanks for this is quite the frustrating problem!!!

  44. […] Test auch wirklich sehr gut funktioniert. Ich muss es nur noch auf mein Beispiel anwenden. Im Blog von Matt Heerema lässt sich dieses finden. Gru soyo __________________ Aktuelle Zertifizierung: MCP 70-270 In […]

  45. Giles Avatar
    Giles

    This is an awesome hack but as ever, IE manages to mess it up however hard you try: I have a fieldset with a semi-transparent PNG background. so:

    <code>.my_fieldset {

    background:transparent;

    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='images/bg/1px_gray_20pc.png');

    }</code>

    With this kind of CSS PNG background, IE decides to crop the legend at the top of the fieldset. If you change the background to a normal background:#f00; type declaration, the legend displays as normal.

  46. Getting Fieldset Backgrounds and Legends to Behave in IE…

    […]The title says it all. Very useful![…]…

  47. Flick Avatar

    Thanks! :) This worked great!

  48. IE must die Avatar
    IE must die

    Regarding the comment by Giles, this problem also occurs when using a transparent PNG sans the MS filter hack. So, even if you support IE 7 only, you are screwed by IE once again.

    That said, I cannot get any of the posted methods to work in IE 6 or 7. I still get a few pixels of bleed out the top. I stripped the styles down to nothing first to be sure the css applied to real browsers in my first style sheet were not causing issue. I'm glad others have had success, but I can no longer waste time on IE and have decided to display it plain and ugly. Sad, because that's what most users of my app use( corporate customers ). They'll never see the great design I had…

  49. Darren Emory Avatar

    Nice tutorial. Fixed a stupid issue for me! Thanks

  50. Joel Avatar

    Thanks. Fixed a big problem for me.

  51. Jesse Avatar

    A w e s o m e !

  52. bob Avatar
    bob

    THANK YOU FOR THIS!!

  53. […] Getting Fieldset Backgrounds and Legends to Behave in IE I’m sure someone has posted on this issue before I just haven’t found an answer I’m looking […]

  54. Paolo Avatar

    Thanks, useful guide. it's easy and simple. I'll try your solutions right now… :)

  55. […] Getting Fieldset Backgrounds and Legends to Behave in IE I’m sure someone has posted on this issue before I just haven’t found an answer I’m looking […]

  56. […] mattheerema adresinde gördüÄŸüm faydalı bir makale ekliyorum. Sayfalarınızda Fieldset ve Legend takılarını kullanırken eÄŸer fieldset takısına zemin rengi atarsanız IE tarayıcılarda legend takısına bu zemin renginin taÅŸdığını görüyoruz. AÅŸağıdaki küçük CSS eklemeleri ile bu sorundan kurtulabiliyoruz. […]

  57. MP145 Avatar
    MP145

    Thanks Matt…i have to say Voila! too :)

  58. asdfasdf Avatar
    asdfasdf

    asdfsdaf

  59. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  60. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  61. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  62. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  63. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  64. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  65. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  66. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  67. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  68. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  69. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  70. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  71. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  72. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  73. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  74. T-Shirt Girl Avatar

    Wow this is a two year old bug and I was still searching for it – thanks for finding a solution two years ago ;-)
    Léonie.

  75. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  76. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  77. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  78. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  79. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  80. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  81. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  82. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  83. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  84. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  85. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  86. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  87. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  88. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  89. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  90. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  91. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  92. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  93. Rollo Avatar
    Rollo

    Thanks Matt for this useful tip. Really helped.

  94. […] Getting Fieldset Backgrounds and Legends to Behave in IE – Matt Heerem […]

  95. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  96. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  97. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  98. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  99. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  100. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  101. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  102. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  103. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  104. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  105. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  106. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  107. nicolas Avatar
    nicolas

    Damn! I was having yhe very same problem! Good I quickly found this page. Thank you!

    IE sucks, and it ever will.

  108. hjgj Avatar
    hjgj

    gfhfghg

  109. hjgj Avatar
    hjgj

    gfhfghg

  110. hjgj Avatar
    hjgj

    gfhfghg

  111. hjgj Avatar
    hjgj

    gfhfghg

  112. hjgj Avatar
    hjgj

    gfhfghg

  113. hjgj Avatar
    hjgj

    gfhfghg

  114. hjgj Avatar
    hjgj

    gfhfghg

  115. hjgj Avatar
    hjgj

    gfhfghg

  116. hjgj Avatar
    hjgj

    gfhfghg

  117. hjgj Avatar
    hjgj

    gfhfghg

  118. hjgj Avatar
    hjgj

    gfhfghg

  119. hjgj Avatar
    hjgj

    gfhfghg

  120. hjgj Avatar
    hjgj

    gfhfghg

  121. John Avatar

    Have to agree, IE always causes pain at the wrong times!!! It’s better than it used to be though to be fair!

    Cheers, John

  122. […] For IE7, the background color doesn’t appear at all, which might actually be better than to have it appear incorrectly. So the appearance definitely won’t be as sharp for your IE users as for any other browser user. (Yet another reason to encourage your clients, friends, associates, neighbors and strangers on the street to avoid Internet Explorer. We can eliminate it in our lifetimes.) (UPDATE: there are, of course, work-arounds. Here are a few suggestions from Sitepoint and CommunityMX and Matt Heerema.) […]

  123. Sedat Kumcu Avatar
    Sedat Kumcu

    Thanks for this article. Best regards man.

  124. thetooman Avatar
    thetooman

    It appears the iE8 has some weird different spacing. My ugly solution was contitional commenting thusly:

    fieldset legend {
    position: absolute;
    /* all ie browsers except .. */
    top: -0.8em;
    left: 0.7em;

    /* … ie6,7 http://paulirish.com/2009/browser-specific-css-ha… */
    *top: -0.5em;
    *left: 0.2em;
    }

  125. pnanh Avatar
    pnanh

    thanks yours tip

  126. Mirko Avatar

    Thanks for the nice trick!

  127. Fentex Avatar
    Fentex

    The fundemental problem with fieldset legends is that they can’t be rendered using CSS to style them.

    The way legends appear for fieldsets requires displaying partial transparencies just not supported by any CSS standard (they have to be transparent, but not to borders).

    Thus each browser manufacturer has created their own solution to how to display fieldsets with legends.

    The method here generally works but fails when certain borders are specified because IE still leaks a borders width above the top border.

    The way to fix that problem is to not give the fieldset a top border and use a x repeating background image in it’s stead.

    1. NaM - The French frog x) Avatar

      Thanks a lot for both tricks!
      As mentionned by Fentex, after have applied the first trick, another problem was still there : the top-border of the fieldset that overflows to the right.
      I simply deleted the top border and thanks to the background applied to my fieldset i don’t need to add any other trick!!
      This is just perfect!
      Thanks so much x)

  128. […] decided to test it out on the infamous fieldset – legend IE bug.  The display issue came to my attention not by IE, which had been fixed using the usual […]

  129. John Griffiths Avatar

    mine was a bit more intense, ended up using position:static to fix it.

  130. לימודי הנדסת מכונות Avatar
    לימודי הנדסת מכונות

    Finally a solution!! Thanks!

  131. chanteur06 Avatar
    chanteur06

    Wonderful ! TKS a lot!

Leave a Reply

Your email address will not be published. Required fields are marked *