How to style an hr element with CSS?

CSSWeb DevelopmentFront End Technology

To style an hr element with CSS, the code is as follows −

Example

 Live Demo

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<style>
   body{
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      margin: 20px;
   }
   hr{
      margin-bottom: 20px;
   }
   .solid {
      border-top: 5px solid rgb(16, 2, 141);
   }
   .dashed {
      border-top: 5px dashed rgb(190, 13, 146);
   }
   .double {
      border-top: 5px double rgb(22, 145, 11);
   }
   .dotted {
      border: 5px dotted rgb(200, 255, 0);
   }
   .round {
      border: 5px solid rgb(35, 196, 142);
      border-radius: 5px;
   }
</style>
</head>
<body>
<h1 style="text-align: center;">HR styling example</h1>
<hr class="solid">
<hr class="dashed">
<hr class="double">
<hr class="dotted">
<hr class="round">
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 07-May-2020 15:57:01
Advertisements