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 trialDylan Carter
4,780 Pointsform attributes, "name" vs "id"....?
Hey everyone,
just had a quick question that i wanna make sure i have straight.
with the two above attributes, am i correct by saying that the id is used for our css and such, while the name would be used more as a "variable" for JS or any backend programming?
2 Answers
Mikkel Rasmussen
31,772 PointsIndeed that is correct.
Jeremy Castanza
12,081 PointsI've tried thinking of it like this... ID is for the front-end developer (i.e. Used for Design). Name is for the back-end developer (i.e. Used for Data).
Mikkel Rasmussen
31,772 PointsMikkel Rasmussen
31,772 PointsExample:
<input type="number" name="user_number" id="nm">
To access its value with php you would write:
filter_input(INPUT_POST, "user_number");