+ 1

What is diferance between class selector and Id selector?

Class and Id selector both are use in a page multiple time. So, what is diferance between them.

11th Apr 2019, 3:13 PM
Laxmi Khatri
Laxmi Khatri - avatar
2 ответов
+ 7
First let's identify what is the difference between classes and id. ID - a unique attribute for an element. 2 elements cannot have the same id. Selectors usually have #ID_NAME syntax class - Can apply to many elements . not unique. Selectors usually have .CLASS_NAME syntax. Id selectors are much more powerful than class and they can override properties defined in classes. This doesn't mean that you have to use IDs everywhere. You can use it when an element is going to be unique than others. Classes are useful when applying styles or scripts to elements where common behaviours are expected.
11th Apr 2019, 3:25 PM
Seniru
Seniru - avatar
+ 1
Thank you so much to help me 😊😊😊
11th Apr 2019, 3:28 PM
Laxmi Khatri
Laxmi Khatri - avatar