CSS border-color Property
Example
Set a color for the border:
Definition and Usage
The border-color
property sets the color of an element's four borders. This property can have from one to four values.
If the border-color property has four values:
- border-color: red green blue pink;
- top border is red
- right border is green
- bottom border is blue
- left border is pink
If the border-color property has three values:
- border-color: red green blue;
- top border is red
- right and left borders are green
- bottom border is blue
If the border-color property has two values:
- border-color: red green;
- top and bottom borders are red
- right and left borders are green
If the border-color property has one value:
- border-color: red;
- all four borders are red
Note: Always declare the border-style property before the border-color
property. An element must have borders before you can change the color.
Default value: | The current color of the element |
---|---|
Inherited: | no |
Animatable: | yes. |
Version: | CSS1 |
JavaScript syntax: | object.style.borderColor="blue" |
- Inherited : "Inherited = no" means that it cannot takes (inherit) it's value from it's parent element.
- object - object in javascript means the element on which
border-color
is applied. - Animatable - "Animatable = yes" means that it can be animated with CSS
@keyframes
.
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
border-color | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
CSS Syntax
Property Values
Value | Description | Demo |
---|---|---|
color | Specifies the border color. Default color is the current color of the element | |
transparent | Specifies that the border color should be transparent | |
initial | Sets this property to its default value. | |
inherit | Inherits this property from its parent element. |
More Examples
Example
Set a color for the border with a HEX value:
Example
Set a color for the border with an RGB value:
Example
Set a color for the border with an RGBA value:
Example
Set a color for the border with a HSL value:
Example
Set a color for the border with a HSLA value:
Example
Set a different border-color for each side of an element:
div.ex2 {border-color: #ff0000 #0000ff;}
div.ex3 {border-color: #ff0000 #00ff00 #0000ff;}
div.ex4 {border-color: #ff0000 #00ff00 #0000ff rgb(250,0,255);}
Comments
Post a Comment