1. css
  2. /properties
  3. /border-right-color

border-right-color

Definition

border-right-color is a CSS property that allows you to set the color of the right border of an element. It is used to define the color of the right border of an element. The color can be set using a keyword (such as "red" or "blue"), a hex value (such as "#ff0000" or "#0000ff"), or an RGB value (such as "rgb(255, 0, 0)" or "rgb(0, 0, 255)").

Examples

This will give the element with the class "red-border" a red colored, solid, 2px width right border:

.red-border {
  border-right-color: red;
  border-right-style: solid;
  border-right-width: 2px;
}

This will give the element with the class "blue-border" a blue colored, dotted, 4px width right border:

.blue-border {
  border-right-color: #0000ff;
  border-right-style: dotted;
  border-right-width: 4px;
}

This will give the element with class "border-with-rgba" red colored, double, 6px width right border with 50% opacity:

.border-with-rgba {
  border-right-color: rgba(255, 0, 0, 0.5);
  border-right-style: double;
  border-right-width: 6px;
}

This will give all the border of the element with class "all-border-color" solid, 2px width border, top border color as red, right border color as green, bottom border color as blue and left border color as yellow:

.all-border-color {
  border-color: red green blue yellow;
  border-style: solid;
  border-width: 2px;
}

Values

SyntaxDescription
border-right-color: <color>Defines the color of the right border of an element using color keywords, hex values, and RGB values.
border-right-color: transparentSpecifies that the right border color should be transparent.
border-right-color: invertSpecifies that the right border color should be inverted.
border-right-color: currentcolorSpecifies that the right border color should be the same as the current color of the text.
border-right-color: initialSets the right border color to its default value.
border-right-color: inheritInherits the right border color value from its parent element.

Best Practices

  • Be consistent: When using border-right-color to create borders, it's important to be consistent with the color values you use. For example, if you use a red color on one element, you should use the same color value on similar elements.
  • Use meaningful colors: When defining the border color, it's best to use colors that are meaningful to the content. For example, if you are highlighting an error message, it's better to use a color like red rather than blue.
  • Consider accessibility: Keep in mind that some users may have difficulty distinguishing certain colors, so make sure to use colors that have a good color contrast ratio to ensure that your content is accessible to all users.
  • Use CSS variables for easy maintenance: If you have multiple element that shares the same border color, it's a good idea to use CSS variables so that you can easily update the color throughout your project.
  • Use the shorthand property: To set the border-right-color property, it's best to use the border-color shorthand property to set all border color at once. It makes your CSS code more concise and easier to maintain.
  • Use rgba color: if you want to use transparent border, you can use the rgba color function, it helps you to adjust the transparency level of border color.
  • Combine with other properties: You can combine border-right-color property with other border properties such as border-right-width and border-right-style to create more visually appealing designs.

Browser Compatibility

ChromeFirefoxSafariInternet ExplorerMicrosoft EdgeOpera
YesYesYesYesYesYes