Sometimes, we want to change the color of an hr element with CSS.
In this article, we’ll look at how to change the color of an hr element with CSS.
How to change the color of an hr element with CSS?
To change the color of an hr element with CSS, we set the border property.
For instance, we write
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
}
to set border-top to the border styles.
We set border to 0 to disable the default border.
Conclusion
To change the color of an hr element with CSS, we set the border property.