How to change the color of an hr element with CSS?

Spread the love

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 color.

For instance, we write

hr {
  display: block;
  height: 1px;
  border: 0;
  border-top: 1px solid #ccc;
  margin: 1em 0;
  padding: 0;
}

to set the hr element’s border color with border-top: 1px solid #ccc; to change its color.

Conclusion

To change the color of an hr element with CSS, we set the border color.

Leave a Reply

Your email address will not be published.