This video demonstrate the difference between id and class in html in very easy way.
Difference between id and class
Id is
used to identify unique element in html to apply css/script.
used to identify unique element in html to apply css/script.
Class is uded to identify group of elemens to apply css/script.
* But there no any default validation
on browser take it as discipline,later you
will notice when we dig into javascript also.
on browser take it as discipline,later you
will notice when we dig into javascript also.
code:
<!DOCTYPE html>
<html>
<head>
<title>Id and class</title>
<style type="text/css">
#firstbox{
background-color: lightblue;
padding: 10px;
color:white;
}
.greenboxes{
background-color: green;
padding: 20px;
color:yellow;
}
</style>
</head>
<body>
<p id="firstbox"> I am in firstbox </p>
<p class="greenboxes"> I am in green box <p>
<p class="greenboxes"> I am in green box </p>
<p class="greenboxes"> I am in green box <p>
</body>
</html>
No comments:
Post a Comment