The HTML class attribute is used to specify a class for an HTML element.
Multiple HTML elements can share the same class.
The class attribute is often used to point to a class name in a style sheet. It can also be used by a JavaScript to access and manipulate elements with the specific class name.
The HTML class attribute example:
<html>
<head>
<style>
.mycolor {
color: red;
}
</style>
</head>
<body>
<div class="mycolor">
<h2>Patna</h2>
<p>Patna is the capital of Bihar.</p>
</div>
<div class="mycolor">
<h2>New Delhi</h2>
<p>New Delhi is the capital of India.</p>
</div>
</body>
</html>