Class and ID Selector in HTML | Difference Between Class and ID Attribute in HTML

Class and ID Selector in HTML - Difference Between Class and ID Attribute in HTML - Class and ID Attribute in HTML - Class and ID Selector in CSS

class and id


Class and ID in HTML:

Difference Between Class and ID Attribute in HTML is that an id is used for identification of one element and class is used for identify more than one elements that are defined in the webpage. 

When we define id for an element, To select that element with a specific id, we write a hash (#) character in the style that we use, followed by the id of that element. Thus, When we define class for an element, To select that element with a specific class, we write a dot (.) character in the style that we use, followed by the class of that element.

Let's take an example:

Short Code:

 


Output:


class and id attributes


Looking Forward:


For more details - Class and ID Selector in HTML | Difference Between Class and ID Attribute in HTML - Best Programming Videos on YouTube - EDUGYAN Channel


 

Thus, Class and ID Selector in HTML is that an id is used for identification of one element and class is used for identify more than one elements that are defined in the webpage.

Post a Comment

0 Comments