Categories
CSS

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

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *