Filter (Advanced Search)
Downloads
0
Views
217
Video

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

Details

The HTML class attribute is used to specify a class for an HTML element.

Multiple HTML elements can share the same class.


Using The class Attribute

The class attribute is often used to point to a class name in a style sheet. It can also be used by a JavaScript to access and manipulate elements with the specific class name.

In the following example we have three <div> elements with a class attribute with the value of "city". All of the three <div> elements will be styled equally according to the .city style definition in the head section:


<!DOCTYPE html>
<html>
<head>
<style>
.school {background-color: tomato;color: white;border: 2px solid black;margin: 20px;padding: 20px;}
</style>
</head>
<body>
<div class="school">
<h2>GSSS KHOKHAR</h2>
<p>GOVT.SEN.SEC.SCHOOL, KHOKHAR</p>
</div> 

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

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

</body>
</html>



Ad