This is a well-known IE bug and occurs regardless of whether you use JavaScript to generate elements or to write HTML yourself.
legend is a child of the fieldset , but since it is slightly above the top edge of the fieldset , IE (incorrectly) extends the background color of the fieldset to contain legend .
A simple solution is to use the absolute position of legend to bring it out of the normal flow of elements and manually adjust its location so that it is approximately the same as usual. Also position the fieldset relative to the legend so that it remains in its vicinity.
Something like this (adjust the values ββas needed):
fieldset { position: relative; margin: 10px; } fieldset legend { position: absolute; top: -0.5em; left: 0.5em; font-size: 14px; font-style: normal; }
source share