C# Programming: Difference between ID and Class in HTML and Css | Learn HTML5

Friday, June 22, 2018

Difference between ID and Class in HTML and Css | Learn HTML5





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.
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.

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