![]() |
VOOZH | about |
The CSS border-color property allows developers to define the color of an element's border, enhancing the visual design of a webpage. It works in conjunction with the border property to provide control over the appearance of borders using various color values like-named colors, hex codes, or RGB values.
By combining border color with border-style and border width, you can create custom borders. For example, using border-color: red green blue yellow; apply different colors to each side of the border, adding a creative touch to your design
border-color: color-value;border-color: top-color right-color bottom-color left-color;Default Value: The current color of the element
Here are the possible values you can use with the border-color property:
| Property Value | Description | Example |
|---|---|---|
| name | Specifies a color name | "blue" |
| Hex | Specifies a hex value | "#0000ff" |
| RGB | Specifies an RGB value | "rgb(0, 0, 255)" |
| transparent | Sets the color to transparent | "transparent" |
This table outlines the different ways you can define a color value in CSS, from named colors to hex.
The border-color property can be set individually for each side of the element using the following specific properties
| Property | Description |
|---|---|
CSS border-left-color Property | Defines the color of the left border. |
CSS border-top-color Property | Specifies the color of the top border. |
CSS border-right-color Property | Determines the color of the right border. |
CSS border-bottom-color Property | Applies a color to the bottom border. |
CSS border-block-color Property | Sets the border color for logical block-level elements in one declaration. |
CSS border-inline-color Property | Controls the border color for logical inline-level elements in one declaration. |
We will understand each property value through the examples:
All the 140 valid CSS color names can be assigned to the border color.
Syntax:
border-color: blue;Example: This example illustrates the border-color property by setting the color using the name value.
Output:
👁 OutputHEX color value can be assigned to the border color. The pair of values in #rrggbb represent RGB values in the hexadecimal system.
Syntax:
border-color: #0000ff;Example: This example illustrates the border-color property by setting the color using the hexadecimal value.
Output:
👁 outputRGB color value can be assigned to the border color. In rgb(r, g, b) values r, g, and b can vary from 0 to 255 for each of three.
Syntax:
border-color: rgb(0, 0, 255);Example: This example illustrates the border-color property by setting the color using the RGB value.
Output:
👁 outputTransparent value can be assigned to the border color. The transparent value effect is not observed as it lets pass the background color pass through it.
Syntax:
border-color: transparent;Example: This example illustrates the border-color property by setting the color using the transparent value.
Output:
👁 OutputThe border-color property may be defined by using one, two, three, or four values, as given below:
- If a single color value is assigned, it will set it to all sides.
- If two color values are assigned, the first color is set to the top and bottom sides and the second color will be set to the left & right sides.
- If three color values are assigned, the first color is set to the top, the second to the left and right, the third is set to the bottom.
- If four-color values are assigned, the colors are set to the top, right, bottom, and left, which follows the clockwise order.
The border-color property is supported by all major browsers, including:
Note: These major browsers fully support the
background-colorproperty across various versions, ensuring consistent rendering of background colors on web pages.