Id and class difference

Hello everybody
please double grueling
what is the difference between id and class
Thank you for reading

id is specific to that element
and class will identify multiple elements

example : id

<p id="para"> hello @anvarovnaparizoda ! </p>

now here i use id para, this id is will identify this p element.
like if i can use this it to style in css or in javascript for my purpose.

id is unique to that element means from our example our id para , i can not use this id to other element

example : class
class is used to group elements for style purpose in css

<p class="users"> hello @user1 </p>
<p class="users"> hello @user2 </p>
<p class="users"> hello @users3 </p>

and so on so i can use my class for grouping purpose

if you still don’t get then read this article you will definetly understand

for id => HTML - The id attribute

for class =>HTML Classes - The Class Attribute


thank you my friend
I understood from your answer.
I can use id in html only once.
I can rework the class
Did I get it right?

yes ! ,
you get it .
we can use id only once which is unique for that element,
we can use calss for grouping element for same purpose, like styling .

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.