HTML Classes

What is Classes in HTML?

The class attribute is often used to point to a class name in a style sheet.


Uses of class in html

The class attribute is often used to point to a class name in a style sheet.definition in the head section

                          
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Styled Paragraphs </title>
   <style>
    .text-color {
      color: red;
      font-size: 18px;
    }

    .container {
      background-color: #f9f9f9;
      padding: 20px;
      border: 1px solid #ccc;
    }
   </style>
 </head>
 <body>

   <div class="container">
     <h1>Welcome to Styled Paragraphs! </h1>

     <div class="text-color">
       <p>This is the first paragraph with red text color. </p>
       <p>This is the second paragraph with red text color. </p>
     </div>

     <p>This paragraph is outside the styled container. </p>
   </div>

   <!-- Add more content or elements as needed -->

</body>
</html>