CSS border-right Property

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

What You’ll Learn

The border-right property sets the width, style, and color of the physical right border in one shorthand rule.

01

Right Side

Physical edge.

02

Shorthand

Width, style, color.

03

solid

Common style.

04

Sidebar Dividers

Accent borders.

05

Longhands

width, style, color.

06

Classic CSS

Universal support.

Definition and Usage

The border-right CSS property is a physical shorthand that sets the border on the right side of an element. It combines border-right-width, border-right-style, and border-right-color in one declaration.

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

💡
Beginner Tip

For multilingual layouts that must adapt to RTL, consider border-inline-end instead of border-right so the accent bar follows the reading direction.

📝 Syntax

border-right accepts border width, style, and color like other border shorthands:

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

Basic Example

border-right.css
.box {
  border-right: 5px solid red;
}

Syntax Rules

  • Sets width, style, and color for the right border side only.
  • Omitted components use initial values: medium, none, currentcolor.
  • Any valid border width, style, and color values are accepted.
  • Always affects the physical right side, regardless of direction or writing-mode.
  • Use longhands when you need to set only width, style, or color on the right side.

⚡ Quick Reference

QuestionAnswer
Initial valuemedium none currentcolor
Applies toRight border side only
InheritedNo
AnimatablePartially (color and width)
Common useSidebar dividers, trailing accents, panel dividers

Default Value

The default value of border-right is medium none currentcolor. No visible border appears until you set a non-none style and a width greater than zero.

💎 Property Values

ComponentExampleMeaning
border-width4px, thin, 0.25remThickness of the right border
border-stylesolid, dashed, dottedHow the right border is drawn
border-colorred, #2563eb, currentcolorColor of the right border

Common Value Types

4px solidsolid right border
3px dasheddashed style
6px solidthick accent

Right Border and Text Direction

border-right always draws on the physical right side. Text direction does not move the border — compare with logical properties when building RTL layouts.

LTR (direction: ltr)

Right border on the right side

RTL (direction: rtl)

Right border still on the right side

border-right vs related properties

PropertyTargetsBest for
border-rightPhysical right side onlyRight accent bars and trailing dividers
border-inline-endLogical inline-end sideDirection-aware trailing borders in RTL layouts
border-leftPhysical left side onlyLeft accent bars and LTR quote dividers
borderAll four sidesFull box outlines

👀 Live Preview

A box with a blue border on the right side:

Blue border on the right side.

Uses border-right: 4px solid #2563eb;.

Examples Gallery

Try border-right with solid red borders, sidebar dividers, RTL comparison, and dashed styles.

📚 Basic Right Borders

Add a border on the physical right side of an element.

Example 1 — 5px Solid Red Border

Add a solid red right border on a box, matching the reference tutorial.

border-right-basic.html
<style>
  .box {
    border-right: 5px solid red;
    padding: 10px;
  }
</style>

<div class="box">
  This box has a 5px solid red right border.
</div>
Try It Yourself

How It Works

The shorthand sets width, style, and color on the right side only. Other sides keep their default borders unless you set them separately.

Example 2 — Sidebar Divider

Use a right border as a vertical divider on sidebar panels or callouts.

border-right-sidebar.css
.panel {
  max-width: 16rem;
  padding: 0.75rem 1rem;
  border-right: 4px solid #2563eb;
  background: #eff6ff;
  color: #334155;
}
Try It Yourself

How It Works

A right-side border creates a vertical accent at the physical right edge. Pair it with padding so text does not touch the border line.

🎨 RTL and Style Variations

See how border-right behaves in RTL and with different styles.

Example 3 — border-right in RTL

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

border-right-rtl.html
<style>
  .rtl-box {
    direction: rtl;
    padding: 0.75rem 1rem;
    border-right: 4px solid #059669;
    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 instead.

Example 4 — Dashed Right Border

Use a dashed style for a lighter right-edge accent.

border-right-dashed.css
.note {
  padding: 0.75rem 1rem;
  border-right: 3px dashed #7c3aed;
  background: #faf5ff;
}
Try It Yourself

How It Works

Any valid border style works on the right side. A dashed right border adds visual emphasis without a full box outline.

🧠 How border-right Works

1

You set width, style, and color

The shorthand combines all three border components for the right side in one rule.

Shorthand
2

Browser draws the right edge

border-right applies only to the physical right side of the element box.

Apply
3

Other sides stay unchanged

Top, right, and bottom borders keep their own values unless you set them separately.

Scope
=

Right border applied

Your element shows a styled border on the physical right edge.

Modern Browser Support

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

Baseline · Modern browsers

Physical right borders in every browser

Chrome, Edge, Firefox, Safari, and Opera have supported border-right 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 property 99% supported

Bottom line: border-right is one of the most reliable CSS border properties across all browsers.

Conclusion

The border-right property controls the border on the physical right edge. Use it for sidebar dividers, trailing accents, and panel borders in classic LTR layouts.

Combine width, style, and color in one shorthand, or use border-right-width, border-right-style, and border-right-color when you need finer control.

💡 Best Practices

✅ Do

  • Use right borders for sidebar dividers and trailing callout accents
  • Pair with padding so text does not touch the border
  • Use border-inline-end instead when RTL support is required
  • Combine width, style, and color in one shorthand when all three are needed
  • Use longhands when only one component needs to change

❌ Don’t

  • Expect border-right to move to the left in RTL text
  • Mix conflicting physical and logical border rules on the same element
  • Use border-right for trailing accents when direction-aware borders are needed
  • Forget a visible style — width alone may not show a border
  • Hard-code right borders when a logical property would be clearer

Key Takeaways

Knowledge Unlocked

Five things to remember about border-right

Use these points when styling physical right borders.

5
Core concepts
02

Default none

No border.

Default
🔀03

5px solid

Common pattern.

Values
🌐04

Fixed right

Not logical.

Physical
🛠05

Sidebar dividers

Real use case.

Usage

❓ Frequently Asked Questions

The border-right property is a shorthand that sets the width, style, and color of the physical right border of an element in one declaration.
The initial value is medium none currentcolor, which means no visible border unless you set width, style, or color explicitly.
border-right always targets the physical right side of an element, regardless of text direction or writing mode.
border-right is fixed to the physical right side. border-inline-end follows writing direction, so it moves to the left in RTL layouts.
Use it for sidebar dividers, trailing accent bars, and right-edge highlights where the border should stay on the physical right side.

Practice in the Live Editor

Open the HTML editor, try border-right, and preview right border styles 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