CSS The Class selector (for all elements) Code For Website - Learn About Website | DaddyFile

0

The class Selector Element Explain

The class selector selects elements with a specific class attribute.
To select elements with a specific class, write a period (.) character, followed by the name of the class.
In the example below, all HTML elements with class="center" will be red and center-aligned.



Html Code:

<!DOCTYPE html>
<html>
<head>
<style>
.center {
    text-align: center;
    color: red;
}
</style>
</head>
<body>

<h1 class="center">Red and center-aligned heading</h1>
<p class="center">Red and center-aligned paragraph.</p>

</body>
</html>





Html Code Result:

Red and center-aligned heading

Red and center-aligned paragraph.

Post a Comment

 
Top