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.
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,489 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,348 Points