Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Borders, Outlines and Shadows

The border-right property

Reference for the CSS border-right shorthand: set the width, style and color of only the right border, with examples, defaults and logical alternatives.

The border-right property is a shorthand that sets the width, style and color of an element's right border only. Its longhands are border-right-width, border-right-style and border-right-color.

Typical uses are vertical dividers between side-by-side items, such as a sidebar edge or the separators in a horizontal menu.

CSS
.sidebar {
  border-right: 1px solid #cbd5e1;
}

Try it

Vertical dividers

The last menu item removes its right border so the row does not end with a stray separator.

Syntax

CSS
border-right: <line-width> || <line-style> || <color>
  • Initial value: medium none currentcolor
  • Applies to: all elements
  • Inherited: no
  • Animatable: yes (width and color; style is discrete)
  • Computed value: see the longhands

Values

Value Description
<line-width> A length or thin, medium, thick. See border-width.
<line-style> solid, dashed, dotted, double, groove, ridge, inset, outset, none, hidden. See border-style.
<color> Any color value; omitted means currentcolor.

Usage notes

  • Needs a style. border-right: 2px red draws nothing; add solid.
  • Separators. Put the border on every item and remove it from the last one with :last-child, or use the li + li pattern with border-left so no cleanup is needed.
  • Right means right, not "end". In right-to-left languages the content flows toward the left, and a physical right border ends up on the wrong side. Use border-inline-end (see border-inline) when the divider should follow the reading direction.
  • Override order. Declare border before border-right so the more specific rule is the one that remains.
  • Scrollbars. A right border sits outside the scrollbar of the element and does not overlap it.
  • Layout. Adds to the width under content-box; box-sizing: border-box keeps the total width fixed.

Browser support

Supported in every browser.