Id vs Class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Id vs Class

Hello, so they say that in an html code, the "id" is unique -couldn't be used more than once, and the "class" notion isn't, so you can use it how-much-ever you wanted to. I basically see this explanation as unclear since I've tried using the same "id" in different tags e.g: <p id="test">...</p> , <div id="test">...</div>. This ended up having both tags affected by the modifications of #test in my css file...How Come? Isn't the ID unique? I'd like a detailed explanation of the diff. between an ID & a class.

11th Sep 2017, 12:34 PM
Bourhan Dernayka
Bourhan Dernayka - avatar
5 Answers
+ 5
The lessons are quite good too. https://www.sololearn.com/Course/HTML/?ref=app
11th Sep 2017, 1:58 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
https://css-tricks.com/the-difference-between-id-and-class/
11th Sep 2017, 12:57 PM
leonmaass
leonmaass - avatar
+ 1
Thanks, excellent article!
11th Sep 2017, 1:23 PM
Bourhan Dernayka
Bourhan Dernayka - avatar
+ 1
No problem :)
11th Sep 2017, 1:24 PM
leonmaass
leonmaass - avatar
0
Yes they are, but not as clear.
11th Sep 2017, 2:10 PM
Bourhan Dernayka
Bourhan Dernayka - avatar