How to create alert messages with CSS?

CSSWeb DevelopmentFront End Technology

To create alert messages 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;
   }
   .alertMessage {
      padding: 20px;
      background-color: #f44336;
      color: white;
      font-size: 20px;
   }
   .close{
      margin-left: 15px;
      color: white;
      font-weight: bold;
      float: right;
      font-size: 22px;
      line-height: 20px;
      cursor: pointer;
      transition: 0.3s;
   }
   .close:hover {
      color: black;
   }
</style>
</head>
<body>
<h1>Alert Message Example</h1>
<div class="alertMessage">
<span class="close" onclick="this.parentElement.style.display='none';">×</span>
<strong>This cannot be revered!</strong> You account will be deleted.
</div>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 07-May-2020 12:16:38
Advertisements