A CSS class , an attribute used to define a group of HTML elements in order to apply unique styling and formatting to those elements with CSS.

Example :

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Class & Element</title>
    <style>
        h1.intro {
            background-color: yellow;
            color: red;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <h1 class="intro">Class & Element Selector</h1>
    <p class="intro">The style is not applied here.</p>
    <h1 class="intro">When used with h1 element style sheet is applied here.</h1>
</body>
</html>

Show Output :

CSS 05 Class and Element Image

Leave a Comment