HTML/CSS IDs and Classes Course Error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

HTML/CSS IDs and Classes Course Error?

On course https://www.sololearn.com/learn/CSS/1080/, (the 3rd article) the following is said: "Class selectors work in a similar way. The major difference is that IDs can only be applied once per page, while classes can be used as many times on a page as needed." However, with my code, I used the id multiple times. https://code.sololearn.com/Wc6qmEabiV3P/?ref=app And it works. Is there an error in the tutorial? Can someone please explain what they mean by "...IDs can only be applied once..."

3rd Jun 2018, 4:20 AM
Andre Daniel
Andre Daniel - avatar
1 Answer
+ 3
No error in tutorial The reason of using id will be understood only if you know about javascript. In js if you need to get the value of the element or need to change the value of the element, ID is used! CSS may work with multiple ones, but incase of js you will get an error..,, 'If you still struggling with this, just mention my name in the comment section, I'll elaborate with sample code Happy to help you
3rd Jun 2018, 4:32 AM
Hemath Kumar
Hemath Kumar - avatar