HTML - Classes

In HTML class attribute makes it possible to define equal style for elements with same class name.here we have two <div> elements that points to the same class name.



<html>
<head>
<title>HTML - Class>/title>
<style>
state {
    background-color:purple;
    color: white;
    margin: 20px 0 20px 0;
    padding: 20px;
}
</style>
</head>
<body>
<h1>History of State</h1>
<hr>
<h2>Gujarat</h2>
<p class="state">Gujarat is a state in Western India, sometimes referred to as the "Jewel of Western India".It has an area of 196,024 km2 (75,685 sq mi) with a coastline of 1,600 km (990 mi), most of which lies on the Kathiawar peninsula, and a population in excess of 60 million. The state is bordered by Rajasthan to the north, Maharashtra to the south, Madhya Pradesh to the east, and the Arabian Sea and the Pakistani province of Sindh to the west. Its capital city is Gandhinagar, while its largest city is Ahmedabad. Gujarat is home to the Gujarati-speaking people of India.</p>
<hr>
<h2>Maharashtra</h2>
<p class="state">Maharashtra is a state in the western region of India and is India's third-largest state by area and is also the world's second-most populous sub-national entity.It has over 112 million inhabitants and its capital, Mumbai, has a population of approximately 18 million. Nagpur is Maharashtra's second capital as well as winter capital.Maharashtra's business opportunities along with its potential to offer a higher standard of living attract migrants from all over India.</p>
</body>
</html>
							

Output

History of State


Gujarat

Gujarat is a state in Western India, sometimes referred to as the "Jewel of Western India".It has an area of 196,024 km2 (75,685 sq mi) with a coastline of 1,600 km (990 mi), most of which lies on the Kathiawar peninsula, and a population in excess of 60 million. The state is bordered by Rajasthan to the north, Maharashtra to the south, Madhya Pradesh to the east, and the Arabian Sea and the Pakistani province of Sindh to the west. Its capital city is Gandhinagar, while its largest city is Ahmedabad. Gujarat is home to the Gujarati-speaking people of India.


Maharashtra

Maharashtra is a state in the western region of India and is India's third-largest state by area and is also the world's second-most populous sub-national entity.It has over 112 million inhabitants and its capital, Mumbai, has a population of approximately 18 million. Nagpur is Maharashtra's second capital as well as winter capital.Maharashtra's business opportunities along with its potential to offer a higher standard of living attract migrants from all over India.


The above example two diff. div tag but single state class apply both div tag.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!