CSS Portal

CSS border-right Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The border-right property controls the visual border that appears along the right edge of a box. It acts as a single-place shorthand for the three longhands that determine the right edge’s width, style and color - border-right-width, border-right-style and border-right-color - and can be used either to override those longhands or to inherit their combined effect. As part of the box model, the right border is conceptually the region between the element’s margin and padding on that side; it is what you see when the element’s outline or inner content is separated from surrounding elements on the right.

Visually and in layout terms, the right border participates in painting and in the element’s computed box size: in the default sizing model the border contributes to the element’s overall outer dimensions, while using a different sizing model may cause borders to be included inside the declared size - see box-sizing for how that interaction works. The border is part of the standard stacking/painting order and will be affected by background, clipping and overflow rules; if you need a decoration that doesn’t affect layout you would use outline instead, since outlines are drawn without occupying space in the box model.

There are several features that change how the right border is rendered. If an image-based border mechanism is used, such as border-image, that image can replace or modify the appearance of the right edge rather than the simple line drawing the longhands produce. Rounded corners created with border-radius will clip or curve the right border where it meets the corners, so the apparent shape of the right edge depends on corner radii as well as border characteristics. For table elements, border behavior can be further modified by table-specific settings like border-collapse, which affects how adjacent cell borders are combined.

In practice, designers often use the right border to create separators, dividers or to emphasize the right side of a component without adding extra markup. For layouts that must adapt to different writing directions, consider the logical-property alternative border-inline-end which maps to the appropriate physical side (right or left) depending on text direction; this helps make designs more robust for internationalization. Finally, remember that the right border’s final appearance results from the combination of its individual longhand settings, any shorthand overrides such as border, and interactions with other visual properties and the surrounding layout context.

Definition

Initial value
See individual properties
Applies to
All elements
Inherited
No
Computed value
See individual properties
Animatable
Yes
JavaScript syntax
object.style.borderRight

Interactive Demo

The rusty swing set creaked a lonely lullaby in the twilight, shadows lengthening like grasping fingers across the dew-kissed grass. A lone dandelion seed, adrift on the breeze, whispered secrets of faraway fields, of dandelion suns and galaxies spun from fluff. Somewhere, beyond the veil of dusk, a coyote laughed, echoing through the stillness like a forgotten memory.

Syntax

border-right: <line-width> || <line-style> || <color> 

Values

Example

<div class="card">
<div class="panel">
<h2>Panel with border-right</h2>
<p>This panel uses <code>border-right</code> to create a vertical separator.</p>
</div>
<div class="content">
<h2>Content Area</h2>
<p>Right side content sits next to the panel.</p>
</div>
</div>
/* Styles for border-right example */
.card {
    display: flex;
    max-width: 800px;
    margin: 40px auto;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

.panel {
    padding: 24px 32px;
    background: #f5fbff;
    border-right: 6px solid #2b9cff; /* border-right: width style color */
    min-width: 260px;
}

.content {
    padding: 24px 32px;
    background: #ffffff;
    flex: 1;
}

/* Responsive: stack panels on small screens */
@media (max-width: 560px) {
    .card {
        flex-direction: column;
    }
    .panel {
        border-right: none; /* remove right border when stacked */
        border-bottom: 6px solid #2b9cff; /* optional bottom border instead */
    }
}

Browser Support

The following information will show you the current browser support for the CSS border-right property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!