CSS border-right Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The border-right property is a shorthand that sets border-right-width, border-right-style, and border-right-color on the physical right edge.

A line appears only when the style is not none. Width defaults to medium and color to currentColor when omitted. It always stays on the right, unlike border-inline-end, which follows writing direction.

Baseline · Widely available.

Not deprecated and not experimental. The physical side border shorthands have been supported across browsers for a long time.

CSS Syntax

syntax.css
border-right: <line-width> || <line-style> || <color> | initial | inherit;

Write one to three values, in any order. The usual pattern is width, style, then color: border-right: 4px solid #2563eb;.

Property Values

ValueDescriptionTry it
<line-width>Thickness: a length, or thin, medium, thick. Default mediumTry it
solidA continuous line on the right edge. Most common styleTry it
dashedA series of short dashes on the right edgeTry it
dottedA series of dots on the right edgeTry it
doubleTwo parallel lines. Needs enough width to show bothTry it
noneNo right border. Initial style. Width and color alone will not showTry it
<color>Right-border color. Default is currentColorTry it
initialResets to the initial right-border values (style none)Try it
inheritInherits this property from the parent elementTry it

How to Use border-right

Pick a style first so the right edge is visible, then set width and color as needed.

  1. Choose the element that should show a line on the physical right side.
  2. Set a style such as solid, dashed, or dotted. Without a style, nothing draws.
  3. Add a width and color when you want them. Omit them to use medium and currentColor.
  4. Use border-inline-end instead when the edge should flip in RTL layouts.
PieceRequired?Role
StyleYes (to show a line)Without it, the right border stays none and invisible
WidthOptionalDefaults to medium if omitted
ColorOptionalDefaults to currentColor if omitted
Physical right onlyBy designDoes not move with writing mode or direction

Live Preview

Change border-right and watch only the right edge update.

Only the right edge changes. Top, bottom, and left stay without a border.

Box

border-right: 4px solid #2563eb

CSS Examples

Each snippet focuses on border-right only. Use Try It Yourself for a live editor.

Example 1 — Solid Right Border

Set width, style, and color on the right edge in one declaration.

CSS
<style>
  div {
    border-right: 5px solid red;
    padding: 10px;
  }
</style>

<div>Right border</div>
Try It Yourself

How It Works

  1. Target the box. The rule styles the div that needs a right edge.
  2. Set the style. solid draws a continuous line. Without a style, nothing appears.
  3. Set the width. 5px is the thickness of that right edge only.
  4. Set the color. red paints the line. Top, bottom, and left stay unchanged.

Example 2 — Dashed Right Border

Use a dashed style for a softer divider on the right.

CSS
<style>
  div {
    border-right: 4px dashed #2563eb;
    padding: 10px;
  }
</style>

<div>Dashed right</div>
Try It Yourself

How It Works

  1. Keep the same shorthand. Width, style, and color still share one property.
  2. Swap the style. dashed replaces the solid stroke with short gaps.
  3. Keep a clear width. 4px makes the dashes easy to see.
  4. Color the dashes. Blue applies only to the right edge.

Example 3 — Double Right Border

Draw two parallel lines on the right. Give the border enough width so both show.

CSS
<style>
  div {
    border-right: 6px double #0f766e;
    padding: 10px;
  }
</style>

<div>Double right</div>
Try It Yourself

How It Works

  1. Choose double. The browser draws two lines with a gap between them.
  2. Give it room. 6px is wide enough for both lines and the space between.
  3. Set the color. Teal fills both lines on the right edge.
  4. One side only. The other three sides stay without a border from this rule.

Edge Cases & Pitfalls

If the right border disappears or looks wrong, check these first.

style

No style means no border

border-right: 5px red still looks empty because style defaults to none. Always include solid or another style keyword.

reset

The shorthand resets omitted parts

Writing border-right: thick green after border-right-style: dotted resets style to none. Put the style inside the shorthand, or set longhands after it.

RTL

Physical right does not flip in RTL

border-right stays on the right even when direction: rtl. Use border-inline-end when the trailing edge should move with text direction.

size

Borders add to the box by default

With content-box sizing, a right border grows the element’s outer width. Use box-sizing: border-box to keep width inclusive of the border.

sides

This shorthand is one side only

For the same look on every side, use border. For the left edge, use border-left.

Browser Support

border-right is a browser CSS property for the box model. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

border-right

Supported in all modern browsers and Internet Explorer. The physical side border shorthands have been part of CSS for a long time.

100% Universal support
Google Chrome All versions
Full support
Mozilla Firefox All versions
Full support
Apple Safari All versions
Full support
Microsoft Edge All versions
Full support
Opera All versions
Full support
Samsung Internet All versions
Full support
Internet Explorer All versions
Full support
border-right Widely supported

Bottom line: Safe everywhere for width, style, and color on the physical right edge. Prefer border-inline-end when the edge should follow writing direction. It is not a runtime API.

Key Takeaways

  • Role: one shorthand for width, style, and color on the physical right edge.
  • Style first: without a visible style, width and color do nothing.
  • Physical: always the right side. Use border-inline-end for logical trailing edges.
  • Defaults: omitted width is medium; omitted color is currentColor; omitted style is none.

One line: border-right paints the physical right edge — include a style, then add width and color as needed.

Frequently Asked Questions

It is a shorthand that sets border-right-width, border-right-style, and border-right-color on the physical right edge in one declaration.
A border needs a visible style. The initial style is none, so width or color alone will not draw a line. Include solid, dashed, dotted, or another style.
Width, style, and color can appear in any order. A common pattern is width then style then color, for example border-right: 4px solid #2563eb.
border-right always paints the physical right side. border-inline-end follows writing direction, so it can move to the left in RTL layouts.
No. It only sets the right edge. Use border for all four sides, or the other side shorthands for top, bottom, and left.
It is Baseline and widely available in all modern browsers and Internet Explorer. It is a browser CSS property, not a Node.js feature.

Next: border-right-color

Learn how to set only the color of the physical right border.

border-right-color tutorial →

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.

8 people found this page helpful