CSS border-right-width Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Box Model & Borders

What You’ll Learn

The border-right-width property sets how thick the right border is on an element. It is useful when you want precise control over sidebar dividers and right-edge accents.

01

Right Width

Physical right edge.

02

thin / medium / thick

Keyword sizes.

03

px / em / rem

Exact length units.

04

medium Default

Browser default size.

05

Needs Style

Pair with style/color.

06

Longhand

Part of border-right.

Definition and Usage

The border-right-width CSS property allows you to specify the thickness of the right border of an element. This property is part of the border longhand family and is used to control the width of the border along the right edge.

By adjusting this property, you can enhance visual separation between elements and create more defined layouts with subtle 1px dividers or prominent accent lines.

💡
Beginner Tip

border-right-width only sets thickness. Add border-right-style: solid; and border-right-color: black; so the border is visible, or use border-right: 5px solid black; as shorthand.

📝 Syntax

The syntax for border-right-width is straightforward. It accepts keyword values or length units.

syntax.css
selector {
  border-right-width: <length> | thin | medium | thick;
}

Basic Example

border-right-width.css
div {
  border-style: solid;
  border-right-width: 10px;
  border-color: black;
}

The value can be a keyword such as thin or a length such as 10px, 0.25em, or 1rem.

Syntax Rules

  • The initial value is medium, typically around 3 to 4 pixels.
  • Keywords: thin, medium, and thick.
  • Length values use units like px, em, or rem.
  • Pair with border-right-style and border-right-color for full control.
  • Use border-right shorthand when setting width, style, and color together.

⚡ Quick Reference

QuestionAnswer
Initial valuemedium
Applies toRight border width only
InheritedNo
AnimatableYes, as a length
Common useSidebar dividers, right accents, emphasis lines

Default Value

The default value of border-right-width is medium, which typically corresponds to a width of around 3 to 4 pixels depending on the browser’s default settings.

💎 Property Values

The border-right-width property accepts keyword values and length units.

ValueDescription
thinA thin border width (typically 1px)
mediumA medium border width (default, typically 3–4px)
thickA thick border width (typically 5–6px)
<length>A specific width using a length unit like px, em, or rem
initialSets the property to its default value
inheritInherits the property value from its parent element
previewthin
previewmedium
previewthick
preview1px
preview4px
preview8px

Right Border Width and Text Direction

border-right-width always sets the thickness of the physical right border. Text direction does not move the border — compare with border-inline-end-width when building RTL layouts.

LTR (direction: ltr)

10px right border width on the right side

RTL (direction: rtl)

Right border width still on the right side

border-right-width vs border-inline-end-width

PropertyTargetsBest for
border-right-widthPhysical right border thicknessSidebar dividers, right accents, and classic LTR layouts
border-inline-end-widthLogical inline-end border thickness (direction-aware)Trailing edge accents that follow text direction in RTL
border-rightWidth, style, and color togetherWhen you want one shorthand for the full right border

👀 Live Preview

A box with a 10px right border width:

This element has a 10px right border width.

Uses border-right-width: 10px; with solid style and black color.

Examples Gallery

Try border-right-width with pixel lengths, keyword sizes, width comparisons, and right-edge overrides.

📚 Basic Right Border Widths

Set the right border width with style and color longhands so the line is visible.

Example 1 — 10px Right Border Width

Set the right border width of a div to 10px, matching the reference tutorial.

border-right-width-10px.html
<style>
  div {
    border-style: solid;
    border-right-width: 10px;
    border-color: black;
    padding: 0.75rem 1rem;
  }
</style>

<div>This div has a right border width of 10px.</div>
Try It Yourself

How It Works

10px sets an exact thickness on the physical right edge. Style and color make the border visible.

Example 2 — thin Keyword on a Sidebar Divider

Use the thin keyword with a dashed blue right border on a sidebar panel.

border-right-width-thin.html
<style>
  .sidebar {
    border-right-width: thin;
    border-right-style: dashed;
    border-right-color: blue;
    padding: 0.75rem 1rem;
  }
</style>

<div class="sidebar">This sidebar panel has a thin right border.</div>
Try It Yourself

How It Works

thin is a keyword that usually maps to about 1 pixel. Pair it with a visible style and color to create a light right accent.

📏 Width Comparisons and Overrides

Compare exact pixel widths and override only the right edge on a full border.

Example 3 — Compare 1px, 4px, and 8px Widths

See how different pixel values change the weight of a right accent bar.

border-right-width-pixels.css
.w-1 {
  border-right: 1px solid #64748b;
}
.w-4 {
  border-right-width: 4px;
  border-right-style: solid;
  border-right-color: #2563eb;
}
.w-8 {
  border-right: 8px solid #dc2626;
}
Try It Yourself

How It Works

Small differences in width create very different visual weight. Use 1px or 2px for subtle UI lines and larger values for emphasis.

Example 4 — Thick Right Accent on a Card

Give all sides a light border, then make only the right edge thicker for a sidebar-style accent.

border-right-width-override.css
.card {
  border: 1px solid #cbd5e1;
  border-right-width: 6px;
  border-right-color: #2563eb;
  padding: 1rem;
  border-radius: 0.5rem;
}
Try It Yourself

How It Works

The border shorthand sets all sides to 1px. border-right-width: 6px; then overrides only the right thickness for a stronger accent bar.

🧠 How border-right-width Works

1

You choose a thickness

Set a keyword like thin or a length like 10px.

Width rule
2

You add style and color

Pair the width with border-right-style and border-right-color.

Border setup
3

The browser draws the right edge

Only the physical right border uses that thickness. Top, left, and bottom sides stay unchanged.

Right edge
=

Sized right accent

Your element gets a clear right accent with the thickness you chose on the physical right edge.

Universal Browser Support

The border-right-width property is supported in all major browsers, including Chrome, Firefox, Safari, Edge, Opera, and Internet Explorer. It is one of the most reliable CSS border properties.

Baseline · All browsers

Reliable right border widths on every platform

Chrome, Firefox, Safari, Edge, and Opera all support border-right-width consistently.

100% Universal support
Google Chrome69+ · Desktop & Mobile
Full support
Mozilla Firefox66+ · Desktop & Mobile
Full support
Apple Safari12.1+ · macOS & iOS
Full support
Microsoft Edge79+ · Chromium
Full support
Opera56+ · Modern versions
Full support
border-right-width property 100% supported

Bottom line: Use border-right-width freely in any project. It works consistently across all browsers.

Conclusion

The border-right-width property is a useful tool for controlling the thickness of the right border of elements. Whether you want a subtle 1px divider or a prominent accent line, adjusting the border width helps you achieve the desired visual effect.

Experiment with keyword values like thin and thick, or use exact lengths such as 2px and 4px to find the best fit for your design needs.

💡 Best Practices

✅ Do

  • Use 1px or 2px for subtle UI dividers on the right edge
  • Pair width with style and color longhands for predictable results
  • Use rem when you want thickness to scale with root font size
  • Use the border-right shorthand when setting all three parts
  • Override only border-right-width when other sides use the border shorthand

❌ Don’t

  • Set width alone and forget a visible border style
  • Use border-right-width when you need a writing-mode-aware logical edge
  • Use very thick borders everywhere in minimal UI designs
  • Mix physical and logical width properties without a clear reason
  • Rely on medium when you need exact pixel control

Key Takeaways

Knowledge Unlocked

Five things to remember about border-right-width

Use these points when sizing the physical right edge.

5
Core concepts
⚙️02

medium Default

Browser default size.

Default
📏03

thin / thick

Quick keywords.

Values
📝04

px / em / rem

Exact lengths.

Units
🔄05

One Edge Only

Other sides unchanged.

Scope

❓ Frequently Asked Questions

The border-right-width property sets the thickness of the border on the physical right side of an element only.
The initial value is medium, which is typically around 3 to 4 pixels depending on the browser.
Width alone does not always show a border. You also need a visible border-right-style such as solid and usually a color, or use the border-right shorthand.
border-right-width always sets the physical right edge thickness. border-inline-end-width follows writing direction, so it moves to the left in RTL layouts.
Length values like 2px, 4px, and 10px are common for sidebar dividers and right accents. Keywords thin, medium, and thick are useful for quick sizing.

Practice in the Live Editor

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