I want to change the color of my hr tag using CSS. The code I’ve tried below doesn’t seem to work:
hr {
color: #123455;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you should use
border-colorinstead ofcolor, if your intention is to change the color of the line produced by<hr>tag.Although, it has been pointed in comments that, if you change the size of your line, border will still be as wide as you specified in styles, and line will be filled with the default color (which is not a desired effect most of the time). So it seems like in this case you would also need to specify
background-color(as suggested by @Ibu).HTML 5 Boilerplate project in its default stylesheet specifies the following rule:
An article titled “12 Little-Known CSS Facts”, published recently by SitePoint, mentions that
<hr>can set itsborder-colorto its parent’scolorif you specifyhr { border-color: inherit }.