What is the difference between class and id in HTML?

By: Shayal Lata | 13 June 2019

S

Sandeep

06 July 2019

There are many differences between class and id in HTML, I'm going to list the few most important differences.

  • In HTML, id is unique whereas class is not.
  • An HTML element can't have more than one id but it can have more than one class. 
  • Two or more elements in an HTML page can't have the same id but can have the same class.
  • The priority of id is higher than that of class in HTML web page. 

1 votes

S

Shivangi Tandan

08 July 2019

The basic difference between ID and Class in HTML:

ID - Id always a unique, in HTML webpage we can call only one time in a whole page BUT

Class - Class is not unique, we can call the same class many times in the HTML web page.

0 votes

K

Katla Srilaxmi

15 July 2019

the main difference is that id must be unique in html,while classes can have duplicates values

0 votes

Your Answer

Advertise With Us

Email us for details: advertise@gdatamart.com

Legal Policy
Sitemap & Support
International
© 2021 GDATAMART.COM (All Rights Reserved)