+ 2

What is differens beetwen id and class?

3rd May 2017, 4:30 PM
Edgar
2 Answers
+ 3
You mean in HTML/CSS? If so: id: Should be unique. Can only be applied to one HTML-element. Each HTML-element can only have one id. class: One and the same class can be applied to multiple HTML-elements. HTML-elements can have more than one class.
3rd May 2017, 4:38 PM
Thanh Le
Thanh Le - avatar
+ 3
ID is unique but CLASS is not. means you can add single / same class name to multiple elements and style applied to that class name will be applied to all the element associated with that class name. on the other hand you can use same/single id to a single element only. For example. if you add an id of 'app' to a div then you cant add the 'app' id to any other elements on the same html file/document. technically you can add same id multiple times but styles will be applied only to the first id selector. For class, you can add that class as much time as you want. if you have any confusion let me know.
3rd May 2017, 4:37 PM
Apel Mahmod
Apel Mahmod - avatar