About Lesson
Definition:
The HTML class attribute is used to specify one or more class names for an element. Commonly, the class attribute points to a class in a style sheet. The class name is case sensitive.
In CSS, you must write a dot ( . ) character followed by the class of the element for selecting the element with a specified class.
This attribute can also be used by JavaScript via the HTML DOM to make certain changes to HTML elements with a specified class name.
Example:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Class</title>
<style>
.demo2 {
color: white;
text-align: center;
background-color: blueviolet;
}
.demo {
color: brown;
font-size: 30px;
}
</style>
</head>
<body>
<h1 class="demo2">HTML CLASSES</h1>
<h3 class="demo">hello!</h3>
<p class="demo">This is class Attribute</p>
</body>
</html>