0
About differences between id attribute and class
id can only be used once at all in whole code?
3 odpowiedzi
+ 1
ID :
YOU CAN ONLY HAVE SINGLE ID NAME MEANS YOU CAN USE ID IN ANY OF HTML TAGS YOU WANT BUT ID NAME GIVEN TO ONE TAG CANNOT BE USED IN ANOTHER.
EG :
<p id="paragraph"></p>
THAN YOU CANT USE ID NAME paragraph IN ANY OTHER TAG HAVING ID.
YOU CAN SELECT IT USING #.
CLASS :
YOU CAN HAVE CLASS NAME AS MUCH AS YOU WANT.
EG :
<p class="paragraph"></p>
<p class="paragraph"></p>
YOU CAN HAVE MULTIPLE CLASS HAVING paragraph AS A NAME.
YOU CAN SELECT IT USING (.).
Hope this detail explanation helps☺️☺️.
+ 1
Its lengthy topic to explain it here but as you are curious I think I should try to break it down in simple words.
Id are used when you want to load your website faster because that particular would be only one on all page thus easy rendering.
Use class when you want to give same style to many tags and it will take time to render.
Hope this explanation helps☺️☺️.
0
thanks for being specific . I find this language stupid ! why use id? when we can use class 😒