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

HTML HTML Forms Form Basics The Input Element

I have a 2 question

1st question

when giving an ID to an input element, Are the choices is yours or you name it, Or it's limited?.I mean by limited you have choices to choose from.

2nd question

when you give a name to an input element should it be like this? user_.... or user_etc or what ever after the underscore you can name it what ever you want right?. Or the choices it limited and you choose from it.

2 Answers

Emmanuel Molina
Emmanuel Molina
9,268 Points

On the 2nd point : you can name your input like you want, even without the user_ but :

  • often the input name is given by the backend developpers (because it's their scripts who will run most of the operation), frontend developper only use it
  • often the name start with an user_ to remind backend developpers to parse it through a security check before using it (because input field are an entry point for XSS attacks)
Rhys Kearns
Rhys Kearns
4,976 Points

What i understood from that - Can you make the ID of an element whatever you like or do they have specific names. You can make an ID anything you want usually it has a meaning to it, for example if I had a paragraph which displayed data for video I would call it something like videoData. And for the naming of a input do you mean like <input name="name?"> - if so then it can be anything you want aswell with the ID.

Thank you Rhys kearns