CSS border-right-style Property

The border-right-style property sets the line style used to draw an element's right border.

It supports styles such as solid, dashed, dotted, double, and several three-dimensional effects. It changes only the style component, leaving the specified border width and color unchanged.

The property controls the physical right border regardless of writing mode or text direction. Its initial value is none, so a visible border style must be specified before the right border can appear.

border-right-style Syntax

The property accepts one border line style keyword or a CSS-wide keyword.

selector {
  border-right-style: solid;
}

The general syntax is:

selector {
  border-right-style: <line-style>;
}

Solid Border

.panel {
  border-right-style: solid;
}

Dashed Border

.panel {
  border-right-style: dashed;
}

Dotted Border

.panel {
  border-right-style: dotted;
}

Double Border

.panel {
  border-right-style: double;
}

No Border

.panel {
  border-right-style: none;
}

Hidden Border

.panel {
  border-right-style: hidden;
}

CSS-Wide Keywords

.inherited {
  border-right-style: inherit;
}
.reset {
  border-right-style: initial;
}
.unset {
  border-right-style: unset;
}
.reverted {
  border-right-style: revert;
}
.layer-reverted {
  border-right-style: revert-layer;
}

Only one line style can be assigned to the right border. Multiple style keywords in the same declaration are invalid.

Property Values

The border-right-style property supports ten line style keywords.

Value Description
none No right border is drawn. The computed border width becomes zero.
hidden No right border is drawn. Has special precedence in collapsed table border conflicts.
dotted Draws the right border as a series of dots.
dashed Draws the right border as a series of short line segments.
solid Draws a single continuous line.
double Draws two parallel lines separated by a gap.
groove Creates a carved or recessed appearance.
ridge Creates a raised or ridged appearance.
inset Creates a border with an inset appearance.
outset Creates a border with an outset appearance.

CSS-Wide Keywords

Keyword Description
inherit Inherits the computed right border style from the parent.
initial Resets the style to none.
unset Resets the style to none because the property is not inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value none
Inherited No
Applies to Elements that support border properties
Computed value As specified
Animation type Discrete
Percentages Not accepted
Property type Longhand
Physical edge Right

The property changes the border's style. It does not directly set the specified width or color.

How It Works

The browser uses border-right-style to determine how the right border is painted.

Step 1: Set the Width and Color

.panel {
  border-right-width: 6px;
  border-right-color: #1769aa;
}

No right border appears because the style is still none.

Step 2: Add a Visible Style

.panel {
  border-right-width: 6px;
  border-right-color: #1769aa;
  border-right-style: solid;
}

The browser draws a 6-pixel solid blue right border.

Step 3: Change the Style

.panel {
  border-right: 6px solid #1769aa;
  border-right-style: dashed;
}

The border becomes dashed without changing its width or color.

Step 4: Use Another Style

.panel {
  border-right: 6px solid #1769aa;
  border-right-style: dotted;
}

The border becomes dotted.

Step 5: Remove the Border

.panel {
  border-right: 6px solid #1769aa;
  border-right-style: none;
}

The computed border width becomes zero, and the border no longer appears.

Use the longhand when you need to change the line style without resetting the existing border width or color.

Border Line Styles

The most commonly used border styles are solid, dashed, dotted, and double.

Solid

.panel {
  border-right: 6px solid #1769aa;
}

A continuous line is useful for dividers, card accents, and section boundaries.

Dashed

.panel {
  border-right: 6px dashed #1769aa;
}

A dashed line can provide a less formal visual separator.

Dotted

.panel {
  border-right: 6px dotted #1769aa;
}

A dotted border uses a series of dots. Their shape and spacing may vary between browsers.

Double

.panel {
  border-right: 9px double #1769aa;
}

A double border uses two parallel lines separated by a gap. The specified width covers both lines and the space between them.

Changing Styles With a Longhand

.panel {
  border-right: 6px solid #1769aa;
}
.panel.dashed {
  border-right-style: dashed;
}
.panel.dotted {
  border-right-style: dotted;
}
.panel.double {
  border-right-style: double;
}

The width and color remain unchanged across these variants.

Style Without an Explicit Width

.panel {
  border-right-style: solid;
}

The browser uses the initial medium width and currentcolor unless those components have been changed elsewhere.

Three-Dimensional Border Styles

Four border styles create a shaded appearance intended to suggest depth.

Groove

.panel {
  border-right: 10px groove #1769aa;
}

The groove style gives the border a recessed appearance.

Ridge

.panel {
  border-right: 10px ridge #1769aa;
}

The ridge style creates a raised appearance.

Inset

.panel {
  border-right: 10px inset #1769aa;
}

The inset style makes the border appear recessed relative to the surrounding surface.

Outset

.panel {
  border-right: 10px outset #1769aa;
}

The outset style makes the border appear raised.

Using a Neutral Color

.panel {
  border-right: 10px groove #888888;
}

Neutral colors can make the light and dark portions of the effect easier to distinguish.

Using currentcolor

.panel {
  color: #1769aa;
  border-right: 10px ridge currentcolor;
}

The border uses the element's text color as the basis for its shading.

Three-dimensional border rendering varies between browsers and may be subtle at small widths. These styles are primarily decorative.

none vs. hidden

Both none and hidden prevent the right border from being drawn, but they behave differently when table borders are collapsed.

none

.panel {
  border-right: 6px solid #1769aa;
  border-right-style: none;
}

The computed border width becomes zero, and no border is drawn.

hidden

.panel {
  border-right: 6px solid #1769aa;
  border-right-style: hidden;
}

The computed border width also becomes zero, and no border is drawn.

Collapsed Table Borders

When a table uses border-collapse: collapse, adjacent cells can have competing borders along the same edge.

In border conflict resolution, hidden takes precedence and suppresses the conflicting border. The none style has the lowest priority and allows another visible border to win.

table {
  border-collapse: collapse;
}
td {
  border: 2px solid #1769aa;
}
td.no-divider {
  border-right-style: hidden;
}

Comparison

Behavior none hidden
Visible border No No
Computed border width Zero Zero
Collapsed table conflict Lowest priority Suppresses competing borders

For ordinary elements, none is generally sufficient. Use hidden when its collapsed table border behavior is specifically needed.

Border Width and Color

The appearance of a right border depends on its width, style, and color working together.

Width, Style, and Color

.panel {
  border-right-width: 6px;
  border-right-style: solid;
  border-right-color: #1769aa;
}

Equivalent Shorthand

.panel {
  border-right: 6px solid #1769aa;
}

Change Style Only

.panel {
  border-right: 6px solid #1769aa;
  border-right-style: dashed;
}

Change Width Only

.panel {
  border-right: 6px dashed #1769aa;
  border-right-width: 10px;
}

Change Color Only

.panel {
  border-right: 6px dashed #1769aa;
  border-right-color: #27ae60;
}

Transparent Border

.panel {
  border-right: 6px solid transparent;
}

The border retains its width but is not visibly painted.

Zero Width

.panel {
  border-right: 0 solid #1769aa;
}

The border is not visible because its width is zero.

No Style

.panel {
  border-right: 6px none #1769aa;
}

The computed width becomes zero because the style is none.

Use a visible style, a nonzero width, and a distinguishable color when the border needs to appear.

Shorthand Interactions

The border-right-style property can be set or reset by several border shorthand properties.

border-right Shorthand

.panel {
  border-right: 6px solid #1769aa;
}

This sets the right border width, style, and color.

Override the Style

.panel {
  border-right: 6px solid #1769aa;
  border-right-style: dashed;
}

The right border becomes dashed while retaining its width and color.

Later Shorthand Reset

.panel {
  border-right-style: dashed;
  border-right: 6px #1769aa;
}

The later shorthand resets the style to none, so the border is not visible.

border-style Shorthand

.panel {
  border-style: solid dashed dotted double;
}

The four values apply to the top, right, bottom, and left borders, respectively. The right border uses dashed.

Override border-style

.panel {
  border: 5px solid #1769aa;
  border-style: solid;
  border-right-style: dotted;
}

All borders are solid except the right border, which is dotted.

border Shorthand

.panel {
  border-right-style: dashed;
  border: 2px solid #1769aa;
}

The later border shorthand resets the right border style to solid.

border-inline-style Shorthand

.panel {
  direction: ltr;
  border-inline-style: dotted dashed;
}

In horizontal left-to-right writing, the second value sets the physical right border style to dashed.

Use the longhand after a shorthand when you want to change only the right border style.

Physical vs. Logical Borders

The border-right-style property always targets the physical right edge. Logical border style properties adapt to writing mode and direction.

Physical Right Border Style

.panel {
  border-right: 6px solid #1769aa;
  border-right-style: dashed;
}

The right border remains dashed regardless of writing direction.

Logical Inline-End Style

.panel {
  border-inline-end: 6px solid #1769aa;
  border-inline-end-style: dashed;
}

In horizontal left-to-right writing, this targets the right border. In horizontal right-to-left writing, it targets the left border.

Logical Inline-Start Style

.panel {
  border-inline-start: 6px solid #1769aa;
  border-inline-start-style: dashed;
}

In horizontal right-to-left writing, this targets the right border.

Writing Mode Comparison

Writing Mode Direction Logical Style Property Matching Right
horizontal-tb ltr border-inline-end-style
horizontal-tb rtl border-inline-start-style
vertical-rl ltr or rtl border-block-start-style
vertical-lr ltr or rtl border-block-end-style

Vertical Writing Example

.panel {
  writing-mode: vertical-rl;
  border-right: 6px solid #1769aa;
  border-right-style: dotted;
}

The dotted border remains on the physical right edge.

Use physical properties when the border must stay on a fixed edge and logical properties when it should follow the writing direction.

Box Sizing and Layout

Changing the right border style can affect layout when the new style changes the computed border width.

Visible Style

.panel {
  width: 300px;
  border-right: 8px solid #1769aa;
}

The 8-pixel border contributes to the element's outer width when box-sizing is content-box.

Changing to none

.panel {
  width: 300px;
  border-right: 8px solid #1769aa;
  border-right-style: none;
}

The computed border width becomes zero, which can reduce the element's outer width.

Changing Between Visible Styles

.panel {
  border-right: 8px solid #1769aa;
}
.panel:hover {
  border-right-style: dashed;
}

The border retains its 8-pixel width when changing between these visible styles.

Using border-box

.panel {
  box-sizing: border-box;
  width: 300px;
  padding: 20px;
  border-right: 8px solid #1769aa;
}

The declared width includes the border and padding.

Keeping Layout Stable

.panel {
  border-right: 8px solid transparent;
}
.panel:hover {
  border-right-color: #1769aa;
}

The border width remains constant while its appearance changes.

For interactive effects, changing border color is often preferable to switching between none and a visible style.

Cascade and Overrides

The CSS cascade determines which right border style applies when multiple declarations target the same element.

Later Declaration

.panel {
  border-right-style: solid;
  border-right-style: dashed;
}

The later dashed value wins when cascade priority is otherwise equal.

Higher Specificity

.panel {
  border-right-style: solid;
}
.panel.featured {
  border-right-style: double;
}

The featured panel uses the more specific declaration.

Shorthand Override

.panel {
  border-right-style: dashed;
  border-right: 5px solid #1769aa;
}

The later shorthand sets the style to solid.

Longhand Override

.panel {
  border-right: 5px solid #1769aa;
  border-right-style: dotted;
}

The later longhand changes only the style.

Physical and Logical Conflict

.panel {
  border-right: 5px solid #1769aa;
  border-right-style: solid;
  border-inline-end-style: dashed;
}

In horizontal left-to-right writing, both style declarations target the right border. The later logical declaration wins when cascade priority is otherwise equal.

CSS Layers

@layer base, components;
@layer base {
  .panel {
    border-right-style: solid;
  }
}
@layer components {
  .panel {
    border-right-style: dashed;
  }
}

For normal declarations, the later layer takes precedence.

When a right border style appears incorrect, check shorthand resets, specificity, cascade layers, and conflicting logical border declarations.

CSS Custom Properties

CSS custom properties can store reusable border style values for components and themes.

Shared Border Style

:root {
  --divider-style: solid;
}
.panel {
  border-right: 5px var(--divider-style) #1769aa;
}

Style With Fallback

.panel {
  border-right: 5px solid #1769aa;
  border-right-style: var(--divider-style, dashed);
}

The fallback is used when the custom property is unavailable or has the guaranteed-invalid value.

Component Variants

.notice {
  --notice-border-style: solid;
  border-right: 5px var(--notice-border-style) #1769aa;
}
.notice.secondary {
  --notice-border-style: dashed;
}
.notice.decorative {
  --notice-border-style: dotted;
}

Theme-Based Style

:root {
  --panel-border-style: solid;
}
[data-theme="decorative"] {
  --panel-border-style: double;
}
.panel {
  border-right: 8px var(--panel-border-style) #1769aa;
}

Separate Border Components

:root {
  --border-width: 6px;
  --border-style: solid;
  --border-color: #1769aa;
}
.panel {
  border-right: var(--border-width) var(--border-style) var(--border-color);
}

Custom properties help keep border styles consistent across reusable interface components.

Interactive States

The right border style can change in response to hover, focus, selection, and other interface states.

Hover State

.panel {
  border-right: 6px solid #1769aa;
}
.panel:hover {
  border-right-style: dashed;
}

Focus State

.form-field {
  border-right: 4px solid #cccccc;
}
.form-field:focus {
  border-right-style: solid;
  border-right-color: #1769aa;
}

Keyboard Focus

.form-field {
  border-right: 4px solid #cccccc;
}
.form-field:focus-visible {
  border-right-style: double;
  border-right-color: #1769aa;
  outline: 2px solid #1769aa;
  outline-offset: 2px;
}

Selected Card

.card {
  border-right: 5px dashed #cccccc;
}
.card.is-selected {
  border-right-style: solid;
  border-right-color: #1769aa;
}

Current Navigation Item

.nav-link {
  border-right: 4px dotted transparent;
}
.nav-link[aria-current="page"] {
  border-right-style: solid;
  border-right-color: #1769aa;
}

Invalid Form Field

.form-field {
  border-right: 4px solid #cccccc;
}
.form-field[aria-invalid="true"] {
  border-right-style: dashed;
  border-right-color: #c0392b;
}

Border style can reinforce interface feedback, but important states should also be communicated through text, labels, or accessible attributes.

Transitions and Animation

The border-right-style property has a discrete animation type. It does not smoothly interpolate between styles such as solid and dashed.

Discrete Style Change

.panel {
  border-right: 6px solid #1769aa;
  transition: border-right-style 0.3s ease;
}
.panel:hover {
  border-right-style: dashed;
}

The style changes discretely rather than gradually transforming from a solid line into dashes.

Smooth Color Transition

.panel {
  border-right: 6px solid #1769aa;
  transition: border-right-color 0.3s ease;
}
.panel:hover {
  border-right-color: #27ae60;
}

The color can interpolate smoothly while the style remains solid.

Smooth Width Transition

.panel {
  border-right: 4px solid #1769aa;
  transition: border-right-width 0.3s ease;
}
.panel:hover {
  border-right-width: 10px;
}

The width can interpolate between compatible lengths, although this may affect layout.

Keyframe Style Animation

@keyframes right-border-style-change {
  0%, 49% {
    border-right-style: solid;
  }
  50%, 100% {
    border-right-style: dashed;
  }
}
.animated-panel {
  border-right: 6px solid #1769aa;
  animation: right-border-style-change 2s linear infinite;
}

The border switches between the two styles at the specified keyframe boundary.

Reduced Motion Preference

.panel {
  border-right: 6px solid #1769aa;
  transition: border-right-color 0.3s ease;
}
.panel:hover {
  border-right-color: #27ae60;
}
@media (prefers-reduced-motion: reduce) {
  .panel {
    transition: none;
  }
}

For smooth interactive effects, animate border color or width rather than border style.

Responsive Design

The right border style can adapt to viewport size, container size, and layout requirements.

Media Query

.panel {
  border-right: 6px solid #1769aa;
}
@media (max-width: 600px) {
  .panel {
    border-right-style: dashed;
  }
}

Container Query

.panel-container {
  container-type: inline-size;
}
.panel {
  border-right: 6px solid #1769aa;
}
@container (min-width: 500px) {
  .panel {
    border-right-style: double;
  }
}

Responsive Border Removal

.sidebar {
  border-right: 2px solid #cccccc;
}
@media (max-width: 600px) {
  .sidebar {
    border-right-style: none;
    border-bottom: 2px solid #cccccc;
  }
}

The right border disappears on smaller screens, and a bottom border provides separation instead.

Responsive Custom Property

:root {
  --divider-style: solid;
}
@media (max-width: 600px) {
  :root {
    --divider-style: dotted;
  }
}
.panel {
  border-right: 6px var(--divider-style) #1769aa;
}

Print Styles

.panel {
  border-right: 6px dashed #1769aa;
}
@media print {
  .panel {
    border-right-style: solid;
  }
}

A solid border may provide a clearer separator in printed documents.

Responsive border styles can help maintain visual separation when layouts change.

Practical Uses

The border-right-style property is useful for separators, decorative accents, navigation indicators, and component variations.

Sidebar Separator

.sidebar {
  padding-right: 20px;
  border-right: 2px solid #d5dce3;
}

Dashed Content Divider

.content-column {
  padding-right: 20px;
  border-right: 3px dashed #1769aa;
}

Dotted Navigation Divider

.nav-item {
  padding-right: 15px;
  border-right: 2px dotted #cccccc;
}

Double Border Accent

.featured-panel {
  padding: 20px;
  border-right: 9px double #1769aa;
}

Selected Card

.card {
  border-right: 5px dashed #cccccc;
}
.card.is-selected {
  border-right-style: solid;
  border-right-color: #1769aa;
}

Decorative Quote

blockquote {
  margin: 20px 0;
  padding-right: 20px;
  border-right: 6px groove #1769aa;
}

Status Indicator

.status-panel {
  border-right: 5px solid #1769aa;
}
.status-panel.pending {
  border-right-style: dashed;
}
.status-panel.complete {
  border-right-style: solid;
}

Use border styles consistently so that visual differences have a clear purpose.

border-right-style Example

The following example demonstrates all ten right border styles using a consistent border width and color.

<div class="border-right-style-demo">
  <div class="demo-box style-none">none</div>
  <div class="demo-box style-hidden">hidden</div>
  <div class="demo-box style-dotted">dotted</div>
  <div class="demo-box style-dashed">dashed</div>
  <div class="demo-box style-solid">solid</div>
  <div class="demo-box style-double">double</div>
  <div class="demo-box style-groove">groove</div>
  <div class="demo-box style-ridge">ridge</div>
  <div class="demo-box style-inset">inset</div>
  <div class="demo-box style-outset">outset</div>
</div>
.border-right-style-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.border-right-style-demo .demo-box {
  box-sizing: border-box;
  padding: 20px;
  border-right-width: 10px;
  border-right-color: #1769aa;
  background-color: #f3f8fc;
  color: #173b5e;
  font-weight: bold;
}
.border-right-style-demo .style-none {
  border-right-style: none;
}
.border-right-style-demo .style-hidden {
  border-right-style: hidden;
}
.border-right-style-demo .style-dotted {
  border-right-style: dotted;
}
.border-right-style-demo .style-dashed {
  border-right-style: dashed;
}
.border-right-style-demo .style-solid {
  border-right-style: solid;
}
.border-right-style-demo .style-double {
  border-right-style: double;
}
.border-right-style-demo .style-groove {
  border-right-style: groove;
}
.border-right-style-demo .style-ridge {
  border-right-style: ridge;
}
.border-right-style-demo .style-inset {
  border-right-style: inset;
}
.border-right-style-demo .style-outset {
  border-right-style: outset;
}
Browser Result
none
hidden
dotted
dashed
solid
double
groove
ridge
inset
outset

Each box specifies a 10-pixel blue right border. The none and hidden examples have no visible border because their computed border widths become zero.

The remaining examples show how the line style changes the border's appearance. Exact rendering may vary slightly between browsers.

Important Considerations

Keep the following points in mind when using border-right-style:

  • Purpose: Sets the line style of the physical right border.
  • Property type: Longhand.
  • Initial value: none.
  • Inheritance: The property is not inherited.
  • Accepted values: Ten line style keywords and CSS-wide keywords.
  • solid: Draws one continuous line.
  • dashed: Draws short line segments.
  • dotted: Draws a series of dots.
  • double: Draws two parallel lines separated by a gap.
  • groove and ridge: Create recessed and raised effects.
  • inset and outset: Create additional three-dimensional effects.
  • none: Prevents the border from being drawn.
  • hidden: Prevents the border from being drawn and has special behavior in collapsed tables.
  • Computed width: Becomes zero when the style is none or hidden.
  • Border color: Must be distinguishable from the background for a visible result.
  • Border width: Must be nonzero for a visible result.
  • Shorthand interactions: Later shorthand declarations can reset the style.
  • Physical edge: Always targets the right side.
  • Logical borders: Can target the same edge depending on writing mode and direction.
  • Box sizing: Changing between none and visible styles can affect layout.
  • Animation: Discrete rather than smoothly interpolated.
  • Custom properties: Can store reusable border styles.
  • Responsive design: Supports media queries and container queries.
  • Accessibility: Border style should not be the only indicator of an important interface state.
  • Browser support: Supported by all major browsers.

Use border-right-style when changing the right border's appearance without resetting its specified width or color.

Browser Support

The border-right-style property is widely supported in Chrome, Edge, Firefox, Safari, and other major browsers.

It is a long-established CSS property and does not require vendor prefixes. The exact appearance of dotted, dashed, and three-dimensional border styles may vary between browsers.

.panel {
  border-right-width: 6px;
  border-right-color: #1769aa;
  border-right-style: solid;
}

For current compatibility details, visit Can I Use? and search for border-right-style.

Specifications

The border-right-style property is defined in the CSS Backgrounds and Borders Module Level 3 specification.

CSS Backgrounds and Borders Module Level 3

The specification defines the supported border line styles and their rendering behavior.