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.
Also specify that only HTML elements which should be affected by a class. To do this, start with the element name, then write the period (.) character, followed by the name of the class.
To select elements with a specific class, write a period (.) character, followed by the name of the class.
Also specify that only HTML elements which should be affected by a class. To do this, start with the element name, then write the period (.) character, followed by the name of the class.
Code:-
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/*When you want to select using class name you can just put dot(.) before the class name*/
.clsname {
background-color: red;
}
</style>
</head>
<body>
<div>
Test Div
</div>
<div class="clsname">
This div have class name
</div>
</body>
</html>
Css:- Class selector
Reviewed by Network security
on
May 23, 2019
Rating:
No comments: