CSS border-right-color Property

Beginner
⏱️ 7 min read
📚 Updated: Jul 2026
🎯 4 Examples
Box Model & Layout

What You’ll Learn

The border-right-color property sets the color of the border on the physical right side only.

01

Right Side

Physical color.

02

Longhand

Color only.

03

Color Formats

Hex, rgb, hsl.

04

currentcolor

Matches text.

05

Override

Recolor right only.

06

Classic CSS

Universal support.

Definition and Usage

The border-right-color CSS property sets the color of the border on the physical right side of an element. It is a longhand of border-right and works alongside border-right-width and border-right-style.

Unlike logical properties such as border-inline-end-color, border-right-color always targets the physical right edge — even in RTL text. That makes it straightforward for classic LTR layouts and right accent dividers.

💡
Beginner Tip

border-right-color only sets color. Pair it with a visible border width and style, or use border: 2px solid; plus this longhand to recolor only the right side.

📝 Syntax

border-right-color accepts any valid CSS color value:

syntax.css
selector {
  border-right-color: color;
}

Basic Example

border-right-color.css
div {
  border: 2px solid;
  border-right-color: red;
}

Syntax Rules

  • Accepts named colors, hex, rgb, hsl, currentcolor, and transparent.
  • Only affects the right border side; other sides keep their own colors.
  • You need a visible border width and style for the color to appear.
  • Always affects the physical right side, regardless of direction or writing-mode.
  • Default is currentcolor, matching the element’s text color.

⚡ Quick Reference

QuestionAnswer
Initial valuecurrentcolor
Applies toRight border color only
InheritedNo
AnimatableYes, as a color
Common useQuote bar accents, right edge highlights, recoloring one side

Default Value

The default value of border-right-color is currentcolor. The right border uses the element’s text color unless you set a different color explicitly.

💎 Property Values

ValueExampleMeaning
Named colorborder-right-color: green;Uses a CSS color keyword on the right side
Hexborder-right-color: #2563eb;Hexadecimal color on the physical right side
HSLborder-right-color: hsl(142, 71%, 45%);HSL functional notation
currentcolorborder-right-color: currentcolor;Matches the element’s text color
transparentborder-right-color: transparent;Makes the right border invisible
green
#2563eb
hsl

Common Value Types

greennamed color
#2563ebhex value
currentcolormatches text

Right Border Color and Text Direction

border-right-color always colors the physical right side. Text direction does not move the border — compare with border-inline-end-color when building RTL layouts.

LTR (direction: ltr)

Red right border on the right side

RTL (direction: rtl)

Right border color still on the right side

border-right-color vs related properties

PropertyTargetsBest for
border-right-colorColor on the physical right side onlyRight accent bars, sidebar dividers, recoloring one side
border-rightWidth, style, and color on the right sideSetting the full right border in one rule
border-inline-end-colorColor on the inline-end side (direction-aware)Trailing edge accents that follow text direction in RTL
border-right-styleStyle on the physical right side onlyChanging solid, dashed, or dotted on the right edge

👀 Live Preview

A box with a blue right border on a gray frame:

Blue border on the physical right side.

Uses border: 3px solid #cbd5e1; and border-right-color: #2563eb;.

Examples Gallery

Try border-right-color with named colors, hex values, currentcolor, and RTL text.

📚 Basic Right Border Colors

Color only the physical right border side.

Example 1 — Red Right Border Color

Change the right border color to red on a box with a visible border, matching the reference tutorial.

border-right-color-red.html
<style>
  div {
    border: 2px solid;
    border-right-color: red;
    padding: 10px;
  }
</style>

<div>
  This div has a red right border.
</div>
Try It Yourself

How It Works

The shorthand sets a border on all sides. border-right-color: red overrides only the right side color while other sides use the default border color.

Example 2 — Hex Color on the Right Side

Use a hex color for the right border while keeping other sides neutral gray.

border-right-color-hex.css
.card {
  border: 3px solid #cbd5e1;
  border-right-color: #2563eb;
  padding: 1rem;
  background: #eff6ff;
}
Try It Yourself

How It Works

All sides start with gray from the shorthand, then border-right-color recolors only the physical right edge to blue.

🎨 currentcolor and RTL

Match text color or see how right border color behaves in RTL.

Example 3 — currentcolor Keyword

Make the right border match the element’s text color.

border-right-color-current.css
.quote {
  color: #7c3aed;
  border: 3px solid #cbd5e1;
  border-right-color: currentcolor;
  padding: 0.75rem 1rem;
}
Try It Yourself

How It Works

currentcolor is the default value. Here it makes the right border purple to match the text while other sides stay gray.

Example 4 — border-right-color in RTL

In RTL text, border-right-color stays on the physical right — unlike border-inline-end-color.

border-right-color-rtl.html
<style>
  .rtl-box {
    direction: rtl;
    border: 3px solid #cbd5e1;
    border-right-color: #059669;
    padding: 0.75rem 1rem;
    background: #ecfdf5;
  }
</style>

<div class="rtl-box">
  حد فيزيكي على اليسار
</div>
Try It Yourself

How It Works

RTL changes text flow but not the physical right edge. For a trailing accent in RTL, use border-inline-end-color instead.

🧠 How border-right-color Works

1

Border must be visible

A width and style on the right side create a border to color.

Setup
2

Color longhand applies

border-right-color sets the physical right edge color only.

Color
3

Other sides stay unchanged

Top, right, and bottom borders keep their own colors unless you override them.

Scope
=

Colored right border

Only the physical right edge shows your chosen color.

Modern Browser Support

The border-right-color property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera.

Baseline · Modern browsers

Physical right border colors in every browser

Chrome, Edge, Firefox, Safari, and Opera have supported border-right-color since the earliest CSS versions.

99% Modern browser support
Google Chrome87+ · Desktop & Mobile
Full support
Mozilla Firefox66+ · Desktop & Mobile
Full support
Apple Safari14.1+ · macOS & iOS
Full support
Microsoft Edge87+ · All versions
Full support
Opera73+ · Modern versions
Full support
border-right-color property 99% supported

Bottom line: Use border-right-color for reliable right-side accent colors in any modern browser.

Conclusion

The border-right-color property controls the color of the physical right border. Use it for sidebar dividers, right accents, and highlights where the border should stay on the right side.

Pair it with border-right-width and border-right-style, or use the border-right shorthand when you want width, style, and color together.

💡 Best Practices

✅ Do

  • Set border width and style alongside color for visible right borders
  • Use currentcolor when the right border should match text
  • Use border-right-color for classic LTR right accent dividers
  • Override one side after a border shorthand to recolor only the right
  • Use border-inline-end-color when the accent must follow text direction in RTL

❌ Don’t

  • Set color alone without a visible border width and style
  • Expect border-right-color to move to the left in RTL layouts
  • Mix conflicting physical and logical color rules on the same element
  • Use border-right-color when the design needs a trailing edge in RTL
  • Forget that the shorthand sets all sides before your longhand override

Key Takeaways

Knowledge Unlocked

Five things to remember about border-right-color

Use these points when coloring physical right borders.

5
Core concepts
02

currentcolor

Default.

Default
🔀03

red

Named color.

Values
🌐04

Fixed right

Not RTL-aware.

Physical
🛠05

Needs width

Color longhand.

Usage

❓ Frequently Asked Questions

The border-right-color property sets the color of the border on the physical right side of an element only.
The initial value is currentcolor, which uses the element's text color for the right border.
border-right-color always targets the physical right side, regardless of text direction or writing mode.
border-right-color only sets color. You also need a visible border width and style on the right side, or use a shorthand like border: 2px solid plus this longhand.
border-right-color is fixed to the physical right side. border-inline-end-color follows writing direction, so it moves to the left in RTL layouts.

Practice in the Live Editor

Open the HTML editor, try border-right-color, and preview right-side border colors instantly.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful