About differences between id attribute and class | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

About differences between id attribute and class

id can only be used once at all in whole code?

27th Jul 2018, 6:13 AM
Armann
Armann - avatar
3 ответов
+ 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☺️☺️.
27th Jul 2018, 6:18 AM
Meet Mehta
Meet Mehta - avatar
+ 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☺️☺️.
27th Jul 2018, 8:13 AM
Meet Mehta
Meet Mehta - avatar
0
thanks for being specific . I find this language stupid ! why use id? when we can use class 😒
27th Jul 2018, 7:25 AM
Armann
Armann - avatar