The HTML class attribute is used to specify a class for an HTML element. Multiple HTML elements can share the same class name.
The class attribute points to a class name defined in CSS.
<style>
.mycolor{
color:red;
}
</style>
<div class="mycolor">
<h2>Patna</h2>
<p>Patna is the capital of Bihar.</p>
</div>
<div class="mycolor">
<h2>New Delhi</h2>
<p>New Delhi is the capital of India.</p>
</div>
<p class="red bold center"> Welcome to Soopro Pathshala </p>
You can assign multiple class names separated by spaces.
.red{
color:red;
}
.center{
text-align:center;
}
A class selector starts with a dot (.).
document.getElementsByClassName("mycolor");
JavaScript can access and manipulate all elements having the same class.
Which symbol is used before a class name in CSS?