Scripsit shapper:
I am creating a form. It has a few labels, inputs and a submit button.
Should I place the button inside the same fieldset as the inputs and
labels? Or in a different fieldset?
On the practical side, it does not matter much.
The fieldset element is, in principle, an element for logical grouping.
Typically, you wrap a set of radio buttons and their labels inside a
fieldset, when they "work together", specifying a "one-of-many" choice.
Or you could use a fieldset that contains fields for a person's name
(e.g., surname, first name, middle name) and their labels; the fieldset
corresponds then to the concept "a person's name". However, such logical
grouping does not matter much to browsers, except for special rendering
of the entire fieldset. This is somewhat unfortunate, since you don't
always want that rendering, and it is difficult to kill it.
Moreover, a fieldset element must have a legend element. Often it is
easy and natural to write one, but not always. (However,
<legend></legendcan be used; it is valid, even if it does not sound
very logical.)
So I would group labels and inputs if they are logically related, and I
would not put a submit button there. I would use just <div><input
type="submit" ...></div>.
Or maybe I should use the following approach:
1. If the form has only one fieldset then the submit button would be
inside the same fieldset has the inputs and labels.
It sounds a bit illogical, and the rendering might be somewhat
misleading to people who are already used to seeing fieldset display for
interrelated fields.
2. If the form has more than one fieldset then the button to submit
the entire form would be placed in a new fieldset.
No reason to put the button in a fieldset, and there would be no natural
legend for it. _If_ you had several submit buttons (which is usually a
bad idea for certain practical reasons), then they might be grouped into
a fieldset, with e.g. <legend>Submit</legend>.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/