Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set background-color on <hr> tag?

Tags:

html

css

Why is the hr tag element not setting to green as coded below?

hr {
  background-color: #00ff00;
}
<hr>
like image 728
cssfan Avatar asked Oct 19 '25 12:10

cssfan


1 Answers

The background-color just sets background for hr. By applying inline styles, we can make it easier. https://jsbin.com/wuvolojuzu/

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <p>Hello</p>
  <hr color="red" width="100%" />
  <p>Hi</p>
</body>
</html>
like image 156
Ranjith Avatar answered Oct 22 '25 02:10

Ranjith