The legend of fieldset
At my job we do a ton of forms. Pages and pages of forms. We also like to roll with the web standards crowd. In order to make our forms more semantic and accessible we tried many different ways of marking up our forms. In this pursuit of the holy semantic form grail we have run into the inflexible nature of legends. Since we use so many form elements, we find it necessary to use many fieldsets to divide the sets of forms. We had a legend for each fieldset, but early on we would just hide our legends and use h4s or h3s to do an over heading for a fieldset. My first thought is if we’re hiding legends, then why would we even use them. So we moved more toward using the legends and not using the h3s or h4s as heading for the fieldsets. The only problem is that legends are great if you want them styled very similar on every project, but they aren’t flexible across browsers and don’t allow for graceful use of sifr if needed.
So this has left me thinking, would it be horrible if I ditched the legends for the time being and used a combination of fieldsets and headers with no legends? Pages still validate in xhtml if you have fieldsets without legends. What are your thoughts?
Mugs Says:
The main reason for using the element is for semantic accessibility. A person using a screen reader (so I’m told) will be alerted that this is a new section of the form.
I tend to think of the tags as signaling page division rather than form division, but if the entire page is a form, or the form is so big that it really takes on the feeling of being part of the page proper, I say use the h3 and h4 . The presence of a new fieldset will still cause the screen reader to give an adequate alert.
I hate legends, too.
August 22nd, 2007 at 2:15 am