Class Selector

The CSS class selector (.) is used to apply styles to multiple elements that share the same class name. It allows for reusable and consistent styling across a webpage.

Syntax 

.classname {
    property: value;
}

Example:

.button {
    background-color: blue;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    text-align: center;
}
/* Styling a specific element (paragraph) with a class */
p.notice {
    font-size: 18px;
    color: red;
}
Explanation
  • .button applies styles to all elements with the button class.
  • p.notice applies styles only to <p> elements with the notice class.

 Multiple Classes

You can assign multiple classes to an element and apply styles accordingly.
.primary {
    color: white;
    background-color: green;
}
.rounded {
    border-radius: 10px;
}
Example in HTML:

<button class="primary rounded">Click Me</button>
Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2025 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz