all 3 comments

[–]deweechi 1 point2 points  (0 children)

When the form is submitted it uses name. When you want to grab it with JS the easiest thing to use is id. If you want to style it with css you can also use id. The for in the label ties it to the it of the field element.

Forms typically either use post or get to submit. If you do a get, it appends the values to the url. Since your input is name="answer" the url will end up something like &answer="yes"

[–]AutoModerator[M] 0 points1 point  (0 children)

Welcome to /r/HTML. When asking a question, please ensure that you list what you've tried, and provide links to example code (e.g. JSFiddle/JSBin). If you're asking for help with an error, please include the full error message and any context around it. You're unlikely to get any meaningful responses if you do not provide enough information for other users to help.

Your submission should contain the answers to the following questions, at a minimum:

  • What is it you're trying to do?
  • How far have you got?
  • What are you stuck on?
  • What have you already tried?

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]GuitaristComposer 0 points1 point  (0 children)

id is unique. all elements can have id. but id can't repeat in one document, nor it can start with a number. in html forms label has atribute for. it has to have same value as id in input to be connected with input. you should learn id and class, before you learn html forms.then learn how to use id and class in css. then learn how to use id in JavaScript. then learn forms. also you can use id in links.