To change the color of an ‘hr’ tag with CSS, you can use the ‘border-color’ property. Here is an example:
hr {
border-color: red;
}
This will change the color of all hr tags on the page to red.
You can also use the ‘background-color’ property to change the color of the background of the hr tag.
hr {
background-color: red;
}
It should be noted that if you use this method it will change the color of the whole hr and not only the border of it.
You can also target a specific ‘hr’ tag by giving it an id or class and then using the id or class to target it in your CSS.
<hr id="my-hr" />
#my-hr {
border-color: red;
}
<hr class="my-hr" />
.my-hr {
border-color: red;
}
This way you can apply different color to different hr tags on the same page.
Also Read:
- How To Remove White Space Under An Image Using CSS
- What are Pseudo Elements And Pseudo Classes?
- Which CSS Property Is Used To Change The Face Of A Font?
- How To Change Background Opacity Without Affecting Text
- Change The Cursor Into A Hand When A User Hovers Over A List Item?
- How To Horizontally Center A DIV With CSS