what are div, classes,id ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what are div, classes,id ??

i began today to learn css but I'm confused. I understood div is a container of other elements but I don't know the difference between class and id and I don't know how this change the css style of a web page

29th Jul 2016, 8:10 PM
Kayleigh
Kayleigh - avatar
2 Answers
+ 2
The benefit of this is that you can have the same HTML element, but present it differently depending on its class or ID. In the CSS, a class selector is a name preceded by a full stop (“.”) and an ID selector is a name preceded by a hash character (“#”).
29th Jul 2016, 9:25 PM
🇮🇳ankitpateldev👔
🇮🇳ankitpateldev👔 - avatar
+ 2
1-You can use class any time and any where you want...but you must use id once 2-with class , you can select many tags , but with id , you can select needle in a hystack ((Select A Tag In Hundreds Tags)) 3-ID is more specific than Class , ID Has 100 score and class is 10 Example: HTML: <p class="color" id="color" > ID Is More Specific</p> CSS: #color { color: red; } .color { color: blue; } So The Paragraph Will Be Red , Because ID Has 90 Score More Than Class
30th Jul 2016, 11:00 AM
Mahbod Sr
Mahbod Sr - avatar