Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML

jason chan
jason chan
31,008 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