×
   ❮     
HTML CSS MySql Javascript SQL PYTHON JAVA C++ C# BOOTSTRAP REACT XML NODEJS ANGULAR DJango Rust Android VUE
     ❯   

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

Example

<!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>
</body>
</html>
Try it Yourself »

Hey there! Let's go for Learn fasta then! It is more than just coding; it is to have the superpower that can solve any problem. Through simple and easy-to-grasp examples you will sail through the learning process. In addition, it is not just about coding– you will acquire competencies on how to solve complex problems, analyze data, and come up with efficient solutions. Shall we start this wonderful journey together! learnfasta.com terms of use, Copyright 2025 All Rights Reserved.