How to style an hr element with CSS?

CSSWeb DevelopmentFront End Technology

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


 Live Demo

<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      margin: 20px;
      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;
<h1 style="text-align: center;">HR styling example</h1>
<hr class="solid">
<hr class="dashed">
<hr class="double">
<hr class="dotted">
<hr class="round">


The above code will produce the following output −

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