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 trialnagamani palamuthi
6,160 PointsHi , what is the difference between using <fieldset> tags for the controls and using <div> s for the controls?
I used div s as the code that I copied was built with div s but Guil uses fieldset tags in the project.
Umy Ikem
21,383 Points<fieldset> is used to group a set of form elements such as <label> & <input> elements. usually has a name attribute. i think it's 1 of those semantically correct type of things where a fieldset element should be used to group form elements even though you can use a div to do the same.
Just like using <div> to group naviagation when the semantically correct way is using the <nav> element. no visible difference just the correct thing to do
2 Answers
Robert Hanviriyapunt
8,229 PointsHi Nagamani, Fieldset is a a more specific tag and makes it easier if you need to do anything with that element in CSS, JavaScript, etc.
nagamani palamuthi
6,160 Pointsthank you so much for all your answers! that cleared it up for me.
Evan Agee
13,088 PointsEvan Agee
13,088 PointsHowdy! That's a great question Nagamani and I'm glad you're asking it.
The fact is that both <fieldset> and <div> will render pretty much exactly the same. The only different is markup semantics. As a front-end developer you should always be trying to use the html element that makes the most sense for the content you're displaying.
<div> tags are very generic layout elements while <fieldset> is a layout element specifically for a set of form fields.
More details here: