Why do we need `for`, `id`, and `name`?

When writing the code for a Textarea Element, why do you need to add the for, id, and name?

<form> <label for="blog">New Blog Post: </label> <br> <textarea id="blog" name="blog" rows="5" cols="30"></textarea>
1 Like

you can, why shouldn’t this be possible? Default text is really useful

the for and id are used to associate the label and the element, the id can also be used for styling

the name is used form submission.


whats the big difference between id attribute and name atrribute


id is for styling and associating input element with label

name attribute is used when sending information to the back-end of your website.


are we learning back end in next section

no, that would be throwing you into the deep. Of course you ca google about form submission to get a general idea. be careful not to drown.


I have tried so many times but this is not working. Text area code academy
Can someone please help!

The “for” attribute is used in the label as the identifier of the label element.
The “id” attribute is used in the elements like input and textarea with the same value as the attribute in the label.
This will help in making a connection with the label element. So during the form submission, it is known which label is connected to which element.

The Name attribute is the identifier for the text attribute. When the form is submitted, the value of the identifier i.e. name attribute is combined with what the user would input and sent.