CSS .Class Selector


The class selector finds elements with the specific class.

The class selector uses the HTML class attribute.

To find elements with a specific class, write a period character, followed by the name of the class:

Syntax

.class {
    css declarations;
}

Example

<!DOCTYPE html>
    <html>
     <head>
        <style type="text/css">
        .paragraph{
        font-size:30px;
        background-color:#888;
        color:#fff;
        padding:5px;
        }
        .two{
        </style>
        </head>
        <body>
        <p class="paragraph">Welcome to CSS Tutorial</p>
     </body>
    </html>
Output

Welcome to CSS Tutorial


Share this article on