Filter (Advanced Search)
Video

Video is not available... Embedded is previous playlist.

Details

HTML elements can belong to more than one class.

To define multiple classes, separate the class names with a space, e.g. <div class="city main">. The element will be styled according to all the classes specified.

In the following example, the first <h2> element belongs to both the city class and also to the main class, and will get the CSS styles from both of the classes: 


<!DOCTYPE html>
<html>
<head>
<title>Multiple Classes</title>
<style>
.school {background-color: tomato;color: white;padding: 10px;}
.main {text-align: center;}
</style>
</head>
<body>
<h2>The class Attribute</h2>
<p>Use CSS to style elements with the class name "school":</p>

<h2 class="school main">GSSS KHOKHAR</h2>
<p>GOVT.SEN.SEC.SCHOOL, KHOKHAR</p>

<h2 class="school">GHS HARAZ</h2>
<p>GOVT. HIGH SCHOOL, HARAZ</p>

<h2 class="school">GSSS SARAINAGA</h2>
<p>GOVT.SEN.SEC.SCHOOL, SARAINAGA</p>


</body>
</html>



Ad
Added to Favorite
Removed from Favorite