What's the use of <label> tag? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's the use of <label> tag?

Hello everyone! I can't seem to understand the way to use the <label> tag in HTML? To me, it just looks like a regular text within a form? Is there a reason why this tag is used here? Also, are these some other uses of this tag that might enlighten me as to the sense of it? I know it's probably a very beginner question but I can't find the explanation of the proper use of this tag in here. Thank you very much for your support!

23rd Apr 2019, 2:04 PM
Sepo
Sepo - avatar
7 Answers
+ 2
Click on the text present at the left side of radio. First set uses label. Second set doesn't. See this: https://code.sololearn.com/WDu934ngAbrZ/?ref=app
24th Apr 2019, 9:19 AM
Kartik
Kartik - avatar
+ 2
One of the uses of label is that when you use input type=radio or checkbox, and you use label for it, then when you click on the label, it alters the value of the radio or checkbox. It basically links each other.
24th Apr 2019, 6:11 AM
Kartik
Kartik - avatar
+ 2
No it's not necessary. If you have a label for input tag, if you click on the text that is in that label, the input can be changed.
24th Apr 2019, 9:02 AM
Kartik
Kartik - avatar
+ 1
do you mean that <label> is necesseary for dealing with the collected data? I thought it was more the "name" part of the <input> tag that was doing this job? or maybe there's still something i dont understand...
24th Apr 2019, 8:57 AM
Sepo
Sepo - avatar
+ 1
i got it!! thank you man, its amazing :))
24th Apr 2019, 11:17 AM
Sepo
Sepo - avatar
+ 1
https://code.sololearn.com/WyCHzgnUweCG/?ref=app updated my code thanks to you ;)
24th Apr 2019, 11:42 AM
Sepo
Sepo - avatar
+ 1
Nice code you have there! 👌🏻 And glad I could help clear one of your doubts.
24th Apr 2019, 11:46 AM
Kartik
Kartik - avatar