The difference between Class and Id in html
Id can be used to identify one element , whereas a Class
can be used to Identify more than one.
Example:
<!DOCTYPE
html>
<html>
<head>
<style>
#myid
{
background-color: pink;
color: black;
padding: 40px;
text-align: center;
}
.name
{
background-color: orange;
color: white;
padding: 10px;
}
</style>
</head>
<body>
<h2>Difference
Between Class and ID</h2>
<h1
id="myid">My Friends name</h1>
<h2
class="name">Gopal</h2>
<p>Gopal
my best friend.</p>
<h2
class="name">Akash</h2>
<p>Akash
also my best friend </p>
<h2
class="name">Arun</h2>
<p>Arun
is funny man.</p>
</body>
</html>
|
Result:
Difference Between Class and ID
My Friends name
Gopal
Gopal my best friend.
Akash
Akash also my best
friend
Arun
Arun is funny man.
EmoticonEmoticon