1. Class is the classes that set the label, and the class property is used to specify which style the element belongs to.
such as style sheets can be added to. content1 {color:red; background: #ff80c0} usage: class= "Content1".
ID is the identity of the set label. The id attribute is used to define the unique style of an element. As a CSS rule #content2 {Font-size:larger} is used as: id= "Content2"
Conceptually not the same (the following two words are more incisive):
class is a style, first defined, then can set to multiple structures/content for easy reuse. This means that the class name can be the same.
id is a label that distinguishes between different structures and content, like your name, If a room has 2 people with the same name, there will be confusion; id is to find the structure/content first, then define the style;
2. Priority issues for attributes
ID priority is higher than class, you can write an example to see. Part of the code is as follows ( I wrote, not written by the original author of Kazakhstan ):
3. About JS
If you want to script an object in the page (JS), then you can define an ID, otherwise can only be used to traverse the page element plus specify a specific attribute to find it, this is a relatively waste of time resources, far less than an ID to simple.