What's the difference between Id and Class type selectors because they seem to work the same way? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's the difference between Id and Class type selectors because they seem to work the same way?

I've applied id to more than one element and still works

26th Dec 2017, 11:28 AM
Abdussamad Nasir
Abdussamad Nasir - avatar
3 Answers
+ 5
Here is an example of how id and class work. Take a look at JavaScript code and you'll see. When we change style of element chose by id, it applies to first element only. And when we change style of element chose by class, we need to define which element we want to style, [0] or [1], and we can apply it to both elements. Write a comment if you need more explanation. https://code.sololearn.com/WoY5rN4SATDn/?ref=app
26th Dec 2017, 12:53 PM
Tim Thuma
Tim Thuma - avatar
+ 3
It's clear now. thanks
26th Dec 2017, 1:35 PM
Abdussamad Nasir
Abdussamad Nasir - avatar
0
I'd is used to call divs when styling
27th Feb 2018, 6:09 PM
Adebowale Sodiq
Adebowale Sodiq - avatar