html change hr color code example

Example 1: how to change the color of the hr tag in html

<style>       
    hr{
        height: 1px;
        background-color: #ccc;
        border: none;
    }
</style>

Example 2: change the color of an hr

hr {
        height: 1px;
        background-color: #ccc;
        border: none;
    }

Example 3: add color to hr tag

<style>
/* Red border */
hr.new1 {
  border-top: 1px solid red;
}

/* Dashed red border */
hr.new2 {
  border-top: 1px dashed red;
}

/* Dotted red border */
hr.new3 {
  border-top: 1px dotted red;
}

/* Thick red border */
hr.new4 {
  border: 1px solid red;
}

/* Large rounded green border */
hr.new5 {
  border: 10px solid green;
  border-radius: 5px;
}
</style>
 
<h2>Style HR</h2>
<p>Default:</p>
<hr>
<p>Different styles of HR:</p>
<hr class="new1">
<hr class="new2">
<hr class="new3">
<hr class="new4">
<hr class="new5">

Example 4: add color to hr tag

border: 1px solid red;

Tags:

Misc Example