Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nested fieldsets

Tags:

html

semantics

Is it semantically correct to represent sub-sections using fieldsets?

= Basic Info =
   First Name: ________
    Last Name: ________

= Address =
Business Name: ________
      Streeet: ________
         City: ________

How do you deal with nested form sections? Isn't there any better way which would also look okay by default?

like image 646
Kamil Tomšík Avatar asked Apr 16 '11 20:04

Kamil Tomšík


2 Answers

Yes, it's semantically correct.

http://dev.w3.org/html5/spec-preview/the-fieldset-element.html

like image 58
Karl Laurentius Roos Avatar answered Oct 24 '22 22:10

Karl Laurentius Roos


You basically asked two questions:

If it's semantically correct your example and if you can nest fielset elements.

Some answers given here were wrong.

It is syntactically correct, but not semantically correct and you can nest fieldset elements.

It is not semantically correct for the very reason that a form it's not a presentational element. Tables are used to display information in rows and columns where you clearly not doing that. A table is not a prop for making good your form and this is how you used it.

Some suggestions you may follow come next.

Referencing the HTML5 standard, I quote from the proposal document: "Each part of a form is considered a paragraph, and is typically separated from other parts using p elements."

http://dev.w3.org/html5/spec/single-page.htm section 4.10

http://dev.w3.org/html5/spec-LC/forms.html

Should answer the nesting question as well.

The question, I guess, arise from the wish of knowing how to section form content. The answer is with fieldsets. The form itself has a meaning, so "yes", it will be a fieldset that will contain all form elements (and it may be disabled).

Coming back to your example, you will have a fieldset for "registration" and sections of the registration grouped by nested fieldsets, as one such section in your example is the "address".

The "better" way of making a form... it depends and I guess it is another question that will remain open to debates until the HTML5 will be ready and implemented correctly in all browsers.

like image 34
Florin Sima Avatar answered Oct 24 '22 23:10

Florin Sima