Skip to main content

Classes And IDs

Classes and IDs | HTML: Classes and IDs both are using to access the particular element in CSS or in JS.

Here is the ClassesAndIds.html:

  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3.   <head>
  4.     <style>
  5.       .class {
  6.         font-size: 20px;
  7.         background-color: yellow;
  8.       }
  9.       #id001 {
  10.         font-size: 30px;
  11.         background-color: orange;
  12.       }
  13.       #id007 {
  14.         font-size: 40px;
  15.         background-color: lightblue;
  16.       }
  17.     </style>
  18.     <title>Classes and Ids</title>
  19.   </head>
  20.   <body>
  21.     <!-- Classes -->
  22.     <div class="class">
  23.       <h3>Class</h3>
  24.       <p>bla bla bla</p>
  25.     </div>
  26.     <span class="class">bla bla bla</span>
  27.     <!-- Ids -->
  28.     <div id="id001">
  29.       <h3>Id</h3>
  30.       <p>bla bla bla</p>
  31.     </div>
  32.     <span id="id007">bla bla bla</span>
  33.   </body>
  34. </html>

Web view of Html:



Here is the Video: