IE Hates Fieldsets, Continued

| No Comments | No TrackBacks

Last week, I posted about how Internet Explorer doesn’t handle fieldsets very well. I focused a lot on the styling issues, which have been covered before, and realized I may not have touched appropriately on the second issue.

As I said before, any content before the legend tag within a fieldset, IE will render outside the fieldset. This isn’t entirely IE’s fault, as it is technically an error condition. Personally, I think HTML 5 should be modified to not require the the legend to be the first (non-text) child of a fieldset, but in the meantime, Internet Explorer’s failure mode leads to some interesting side-effects.

This is because, while the visual representation of that element is outside the fieldset in question, the DOM places the element within the fieldset. This can lead to some strange behaviour in situations like the following:

Viewed in Internet Explorer, each time you click the button, you’ll see the color of the paragraph shown both inside and outside the fieldset change. If you do query selectors, you’ll find two paragraphs within the fieldset, even though only one is rendered inside. This disconnect between the DOM and the visual representation of the page has some interesting implications, and it shows, in my opinion, a particularly poor choice in handling the error condition on the part of the IE team.

Unless the W3C modified the HTML standard to be more flexible about Legend placement (or at least strictly defines failure modes), it’ll be important to always make sure that the legend is the first item in the fieldset, which is mostly only a problem when modifying the legend via JavaScript.

  • StumbleUpon Toolbar Stumble It!

No TrackBacks

TrackBack URL: http://blog.foxxtrot.net/cgi-bin/mt-tb.cgi/344

Leave a comment

About this Entry

This page contains a single entry by Jeff Craig published on July 27, 2009 3:23 PM.

IE Hates Fieldsets was the previous entry in this blog.

YUI3 Version of Chroma-Hash is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Once You Know, You Newegg

μ-updates

  • No Updates!
OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.21-en