(Solved):What is the difference between class and id in HTML?

 

Question

What is the difference between class and id in HTML?

 

EXPERT ANSWER

The id gives a unique number to an element so it will be easier to differentiate. It uses the stylesheet and javascript.

<html>
<body>
<h5 id="mycomputer">Hello </h5>
</body>
</html>

The class attributes can be used when we need to categorize or group HTML objects in terms of styling and event handling.

<html>
<head>
<style>
h3.intro {
  color:

Scroll to top