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 trialEwerton Luna
Full Stack JavaScript Techdegree Graduate 24,031 PointsI 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?
3 Answers
Darryl Mah
5,492 PointsThe 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'Toole
6,366 Pointsyeah its really hard to apply this stuff or see the actual uses when they arent bringing in any css or javascript...
Robert O'Toole
6,366 Points@darryl your explanation helped a lot though thank you