Is there anyone who can guide me about "id" and "class" in HTML? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there anyone who can guide me about "id" and "class" in HTML?

I am confused about "id" and "class" in HTML! please explain me as simple as you can!

28th Jan 2018, 8:39 AM
Ahmad Heidari
Ahmad Heidari - avatar
3 Answers
+ 2
They are attributes that any HTML element can have. Generally, they are used as targets for CSS styling. using #id_name or .class_name to target an id or class. This was I could have several elements with class="green-box" and my stylesheet can target all these with the same styling ID is also used to target points on the page with a link, so you can have a href="#id_name" to jump to the element with this id. Here lies the key difference - IDs should be unique, whereas classes can appear multiple times.
28th Jan 2018, 8:48 AM
Dan Walker
Dan Walker - avatar
+ 1
thank you so much
28th Jan 2018, 9:34 AM
Ahmad Heidari
Ahmad Heidari - avatar
+ 1
Thanks Martin!
28th Jan 2018, 7:08 PM
Ahmad Heidari
Ahmad Heidari - avatar