Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

jason chan
jason chan
31,009 Points

HTML Forms select group and fieldset

I don't really get when to use select and fieldset in the forms element in html.

Thanks please explain

2 Answers

Ariel Aronica
Ariel Aronica
6,646 Points

The "select" element creates the selectable items menu-- each select item will have optgroup, which we can use to label the groups, and next would be the actual option . With fieldset you can think of it as putting those selectable items into groups... Almost like putting each item into a folder that makes sense. It just adds organization to your dropdown list. <br>

<p>fieldset: " Hey, browser. I want to create a selectable list, and I want to organize it into groups." </p>

<p>legend: "Let's give this dropdown menu a name. Why not Job Role?"</p>

<p>select: "I want these items to be selectable."</p>

<p>optgroup: "I want to label my category for these items": It's The non-selectable category title in the dropdown menu-- labeling the items that will list in its group.</p>

option: the item itself<br> <p> I hope this kind of clears it up. Hopefully it doesn't add to your confusion. If so, here are some helpful links. </p>

<p>here's a link to W3: </p> http://www.w3schools.com/tags/tag_select.asp

<p>and another: </p> http://www.w3schools.com/tags/tag_fieldset.asp

In the example of a form that is filled out online, a field set allows for your to visibly break the form in to sections, for example section 1 name and contact info, section 2 what type of web design or development your interested in, section 3 your hobbies or interests. A selection tag will go inside a field set so that you can provide options for someone to select. In the above example of what type of web design or development are you interested in you could provided a list of options that the person filling the form could select from. Hope this helps