The border-color
property is used to set the color of the four borders.
The color can be set by:
Note: If border-color
is not set, it inherits the color of the element.
Demonstration of the different border colors:
p.one {
border-style: solid;
border-color: red;
}
p.two {
border-style: solid;
border-color: green;
}
p.three {
border-style: dotted;
border-color: blue;
}
Result:
The border-color
property can have from one to four values (for the top border, right border, bottom border, and the left border).
p.one {
border-style: solid;
border-color: red green blue yellow; /* red top, green right, blue bottom and yellow left */
}
Try it Yourself »
The color of the border can also be specified using a hexadecimal value (HEX):
Or by using RGB values:
You can also use HSL values:
You can learn more about HEX, RGB and HSL values in our CSS Colors chapters.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!