How to Change the Color of an
Element Using CSS
In HTML, the
The code you provided doesn't change the color of the line because you are using the "color" property, which affects the text color, not the line color. To change the line color, you should use the "border-color" property.
hr { border-color: #123455; }
This will change the color of the
Note that changing the "border-color" will affect the entire line, including any padding or margin added to the
If you also want to change the color of the background behind the line, you can use the "background-color" property:
hr { border-color: #123455; background-color: #efefef; }
This will change the line color to #123455 and the background color to #efefef.
The above is the detailed content of How Do I Change the Color of an HTML Horizontal Rule Using CSS?. For more information, please follow other related articles on the PHP Chinese website!