11

I'm wondering what the suggested usage of <fieldset>s are on a webpage.

For example, on a simple page with just one form (one set of inputs) is it still recommended to use a fieldset? Or should it only be used when there are several forms or several 'sections' on a page ?

Should it only be used on input/edit pages and not display/details pages?

How does including / excluding a fieldset on a page affect usability?

1
  • 1
    The first part of your question is probably best asked on StackOverflow or Doctype, where you'll get a better answer. The second part is great for UI though! :)
    – Rahul
    Sep 3, 2010 at 18:56

2 Answers 2

12

The W3C's HTML Techniques for Web Content Accessibility Guidelines 1.0 notes fieldset as a tag you can use to semantically group fields in a form. You can then label that fieldset with a legend. Depending on how the browser accessing your content works, this could increase accessibility (for instance, a screen reader could indicate that the following section of the form is for alternate shipping addresses, and that would let the visitor know they could possibly skip that section).

You can use a fieldset whenever you want, even if you only have one field. It depends on how you want to semantically describe your content and how concerned you are with making your forms accessible. For instance, a search form containing an input field and submit button could be contained within a fieldset and use a legend, but you could use CSS to hide both and display the form however you want. It's up to you how you want to denote that, including whether you want to use it for input/edit pages or display/details pages.

7

Rahul is correct, though in your example of multiple groups of elements, I'd say it was a must.

A big thing for me is that using a legend with the fieldset adds accessibility for knowledgable users who use "Form mode". If you're providing further information relating to a question in a text or heading it's not "read" in "Form mode" of most readers, but is if you use the legend with the fieldset. It's read as context.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.