HTML Attributes

Please Share On:

7) class Attribute:

The class attribute is used to associate an element with cascading style sheets (CSS).

Syntax:

class = "className1 className2 className3"

Code:

<!DOCTYPE html>
<html>
  <head>
    <title>class Attribute</title>
    <style>
    .className1{
      background-color: violet;
      text-align: center;
      font-weight: 200;
      font-size: 20px;
      }
      
      .className2{
      padding: 10px 10px;
      }
      
    </style>
  </head>
 
  <body>
    <h1>class Attribute</h1>
    <p class = "className1"> The class attribute is used to associate an element with cascading style sheets (CSS). </p> 
    <p class = "className1 className2"> The class attribute is used to associate an element with cascading style sheets (CSS). </p> 
  </body>
</html>               
        

Output:

8) style Attribute:

The style attribute is used to specify CSS rules within the element.

Syntax:

<p style = "font-family: aerial; color: red; font-size: 20px; font-style: italic;"> Some text... </p>

Code:

<!DOCTYPE html>
<html>
  <head>
    <title>style Attribute</title>
  </head>
 
  <body>
    <h1>style Attribute</h1>
    <p style = "font-family:aerial; color: red; font-size: 20px; font-style: italic;"> Some text... </p>
  </body>
</html>      			

Output:

Continue Reading to the next page…

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright @2023. All Right Reserved.


Social media & sharing icons powered by UltimatelySocial