No announcement
 

Class

The class attribute is used to define a class for one or more HTML elements. It allows you to apply a shared style or behavior to multiple elements.

Example:

class.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Class Attribute Example</title>
</head>
<body>
    <h1 class="heading">Welcome to My Website</h1>
    <p class="content">This is some text on the page.</p>
</body>
</html>


Output

Welcome to My Website

This is some text on the page.

In this example, the class attribute is used to assign the class name "heading" to the <h1> element and the class name "content" to the <p> element. You can apply styles or manipulate these elements using CSS or JavaScript by referencing their respective class names.