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.
.sidebar { border-right: 1px solid #cbd5e1; }
Try it
The last menu item removes its right border so the row does not end with a stray separator.
Syntax
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 reddraws nothing; addsolid. - Separators. Put the border on every item and remove it from the last one with
:last-child, or use theli + lipattern withborder-leftso 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(seeborder-inline) when the divider should follow the reading direction. - Override order. Declare
borderbeforeborder-rightso 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-boxkeeps the total width fixed.
Browser support
Supported in every browser.
Related
borderโ all four sidesborder-top,border-bottom,border-leftborder-inlineโ logical inline-axis bordersbox-sizingโ counts borders in the width- Lessons: Borders, The Box Model