How to style labels with CSS?

CSSWeb DevelopmentFront End Technology

To style labels with CSS, the code is as follows −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      margin: 20px;
   }
   span {
      font-size: 18px;
      font-weight: 600;
      color: white;
      padding: 8px;
   }
   .success {
      background-color: #4caf50;
   }
   .info {
      background-color: #2196f3;
   }
   .warning {
      background-color: #ff9800;
   }
   .danger {
      background-color: #f44336;
   }
   .other {
      background-color: #e7e7e7;
      color: black;
   }
</style>
</head>
<body>
<h1>Labels Example</h1>
<span class="success">Success</span>
<span class="info">Info</span>
<span class="warning">Warning</span>
<span class="danger">Danger</span>
<span class="other">Other</span>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 07-May-2020 12:23:37
Advertisements