HTML CLASS

Maha



 HTML Class

  • The HTML class attribute for an element define one or more class names.
  • Any HTML element can use the class attribute. 
  • The name of the  class is case sensitive. 
  • It create a class with period (.) character, followed by a class name.

HTML Class Attribute

  • Class attribute can be defined within <style> ....</style> tags or we can use separate file using the (.) character.
  • The HTML class property specifies one or more class names for an HTML element. 

Syntax:

<tag class="name">Type some content</tag>

Example:



  <!DOCTYPE html>  
  <html
  <title>Html Block & Inline</title
  <head>  
  <style
  .text{   
  color: black;  
  font-family: fantasy;  
  background-color: lightgreen
  }  
  </style>  
  </head>  
  <body>  
  <h1 class="text">This is the first heading</h1>  
  <h2 class="text">This is the Second heading</h2>  
  <h3 class="text">This is the third heading</h3>  
  <h4 class="text">This is the fourth heading</h4>  
  </body>  
  </html>
  

Output:







More topic in HTML

Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send