SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Sesame Street Iimitk's Avatar
    Join Date
    Feb 2006
    Posts
    662
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is using fieldset & legend elements in forms necessary?

    ...I mean from semantic markup point of view. I don't even know what does "legend" semantically means? And although I can make fancy things to these two elements with CSS to make them look like how I want, I'm wondering if using divs and heading elements are less semantically correct?

    What do you think?
    Imagination is more important than knowledge. - Einstein

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Although I didn't previously think so, I now think it's relevant in all cases. You can hide the fieldset borders and the legend if you want with CSS in order to just display a form control and label, plus submit button (like a "search" box). The legend and fieldset border are a bit more relevant, I think, when there are several form controls inside. It serves as a guide, informing the user what these form controls have to do with each other. Look at dialog boxes in Windows. Most of them have fieldsets and legends grouping text, buttons and text input boxes. It's useful to let you know what the purpose of these things is. Also, with very big forms, having several fieldsets (within reason and semantic logic) can help break them up into more manageable units, especially if you give each a meaninful, useful legend (as you always should).

    although I can make fancy things to these two elements with CSS to make them look like how I want
    What you can do with LEGEND is quite limited due to rather buggy behaviour across browsers (particularly in Mozilla I think).

  3. #3
    Sesame Street Iimitk's Avatar
    Join Date
    Feb 2006
    Posts
    662
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not questioning the function of these two elements, Raffles. As you've said, it's quite important and almost mandatory in big forms.

    I have this form which I built using fieldsets and legends to divide relevant info into readable & organized layout. I'm considering, however, changing the markup to use divs and headings. I admit, that using divs and headings allow more control over the form layout than when using fieldsets and legends as you've pointed out correctly. So if I did that, would that mean the markup would be semantically incorrect, because I should be using the original HTML elements intended for the purpose?
    Imagination is more important than knowledge. - Einstein

  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It looks sensible to me (even though I don't understand Arabic). If it was my layout, I'd probably remove the outer fieldset, or maybe just hide its border and try to style the legend a little differently from the others (perhaps centre it if possible).

    I don't really see what you mean about having more control over the layout. The fieldset behaves pretty much like a div. It's just the legend that can be difficult to position. And I wouldn't say using divs and headings would be semantically incorrect, just semantically inferior. My opinion is that yes, you should use the fieldsets that were intended for this very purpose.

  5. #5
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tyssen pretty much summed up here, though he has updated the article since then (with a new article, I might add).

    http://www.tyssendesign.com.au/artic...ends-of-style/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •