W3docs

CSS border-right-color Property

The border-right-color property is used for defining the color of the right border of an element. See all property values with examples.

The border-right-color property defines the color of the right border of an element.

The right border color, combined with top, right, and bottom border colors, can also be defined with the border-color shorthand property.

If you use the border-right-color property, you should first set the border-style or border-right-style properties and then change the color of the defined style.

The default width of a border is medium. You can specify the width using either the border-width or border-right-width properties.

Initial ValuecurrentColor
Applies toAll elements. It also applies to ::first-letter.
InheritedNo
AnimatableYes. The color of the right border is animatable.
VersionCSS1
DOM Syntaxobject.style.borderRightColor = "black";

Syntax

Syntax of CSS border-right-color Property

border-right-color: color | transparent | initial | inherit;

Example of the border-right-color property:

Example of CSS border-right-color Property

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        width: 300px;
        padding: 20px;
        border-style: solid;
        border-color: #ccc;
        border-right-color: #1c87c9;
      }
    </style>
  </head>
  <body>
    <h2>Border-right-color example</h2>
    <div>Example for the border-right-color property with different right border color.</div>
  </body>
</html>

Example of the border-right-color property with the "transparent" value :

Example of CSS border-right-color Property with transparent value

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      h2 {
        padding: 3px;
        text-align: center;
        border: 15px groove #1c87c9;
        border-right-color: transparent;
      }
    </style>
  </head>
  <body>
    <h2>A heading with a transparent right border</h2>
  </body>
</html>
Info

You can set hexadecimal, RGB, RGBA, HSL, HSLA or color names as a value for the border-right-color property.

Result

CSS border-right-color Property

Example of the border-right-color property with a named color:

Example of CSS border-right-color Property with named color value

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        padding: 3px;
        border-right-style: solid;
        border-right-color: black;
      }
    </style>
  </head>
  <body>
    <div>Border-right-color property with a named color value.</div>
  </body>
</html>

Example of the border-right-color property with a hexadecimal value:

Example of CSS border-right-color Property with hexadecimal value

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        padding: 3px;
        border-right-style: solid;
        border-right-color: #1c87c9;
      }
    </style>
  </head>
  <body>
    <div>Border-right-color property with a hexadecimal value.</div>
  </body>
</html>

Example of the border-right-color property with a RGB value:

Example of CSS border-right-color Property with RGB value

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        padding: 3px;
        border-right-style: solid;
        border-right-color: rgb(142, 191, 66);
      }
    </style>
  </head>
  <body>
    <div>Border-right-color property with a RGB value.</div>
  </body>
</html>

Example of the border-right-color property with a HSL value:

Example of CSS border-right-color Property HSL value

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        padding: 3px;
        border-right-style: solid;
        border-right-color: hsl(89, 43%, 51%);
      }
    </style>
  </head>
  <body>
    <div>Border-right-color property with a HSL value.</div>
  </body>
</html>

Values

ValueDescriptionPlay it
colorDefines the color of the right border. Default color is the color of the current element. Color names, hexadecimal color codes, rgb(), rgba(), hsl(), hsla() can be used. Required value.Play it »
transparentApplies a transparent color to the right border. The right border will still take up the space defined by the border-width value.Play it »
initialSets the property to its default value.Play it »
inheritInherits the property from its parent element.

Practice

Practice

What does the CSS property 'border-right-color' do?