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
I don't quite get the difference between the id and name attributes in these cases.
I supose that ID attribute is used to target an element. What's the purpose of the name attribute. Nick explains briefly but it wasn't so clear to me. Couldn't I just use the ID?
Darryl Mah5,492 Points
The purpose of a name attribute, in an input tag, is so that you can access/identify the information submitted by the user, for each input. When a user submits the form, you’ll be able to view the data associated with that particular field, something the ID will not do, at least to my understanding. The ID is used to target the element for your css. In this example it seems a bit redundant to use. Since I’m guessing they applied the css to the input tag, since they all have the same look, and the ID wasn’t used for anything.
Robert O'Toole6,366 Points