what is difference between id and class in css ?

The id selector is used to specify a style for a single, unique element. The id selector uses the id attribute of the HTML element, and is defined with a "#". class: The class selector is used to specify a style for a group of elements.
 
The id selector is used to specify a style for a single, unique element. The id selector uses the id attribute of the HTML element, and is defined with a "#".

class: The class selector is used to specify a style for a group of elements.
 
id: Each element can have only one ID and each page can have only one element with that ID. While with class: You can use the same class on multiple elements and multiple classes on the same element.
 
The id selector is used to specify a style for a single, unique element.The id selector uses the id attribute of the HTML element, and is defined with a "#".

The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements.The class selector uses the HTML class attribute, and is defined with a "."
 
Back
Top