What is the difference between name and id in HTML | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between name and id in HTML

19th Aug 2020, 6:05 AM
Anuj Raghu
Anuj Raghu - avatar
4 Answers
0
name is used in forms to access elements for label or dom manupulation.
19th Aug 2020, 6:57 AM
Divya Mohan
Divya Mohan - avatar
0
name is generally used for form related elements but id is a global attribute you can use it with all tags
19th Aug 2020, 6:45 AM
Divya Mohan
Divya Mohan - avatar
0
You can't access directly an element using name value in css you have to goes through attributes name and value. But with id you can #id{ //Style }
19th Aug 2020, 6:56 AM
Divya Mohan
Divya Mohan - avatar
0
Sorry Label works with id. But form's element names make js dom manupulation much easier
19th Aug 2020, 7:18 AM
Divya Mohan
Divya Mohan - avatar