right
Moves a positioned element in from the right. With absolute or fixed it measures from the right edge of the containing block, and with relative it shifts the element left from where it would normally sit.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyHas a modern alternativeIt still works everywhere, as it has since July 2015, and there's a newer way for most uses.
anchor()Baseline Jan 2026anchor-size()Baseline Jan 2026
Use inset-inline-end. It follows the writing direction, so the same CSS works in right-to-left languages.
When the old way is still right: Keep physical properties when the direction belongs to the screen, not the text, such as a shadow offset or something pinned to the right edge in every language.
The CSS audit finds physical left and right in your code.Check your CSS →
Quick facts
- Initial value
auto- Inherited
- No
- Applies to
- positioned elements
- Animation type
- lpc
Quick example
.close-button {
position: absolute;
top: 0.5rem;
right: 0.5rem;
}Values
auto<length><percentage>anchor()anchor-size()Examples
Pin to the right edge
.card {
position: relative;
}
.card .badge {
position: absolute;
top: 0;
right: 0;
}The badge sits in the top right corner of the card, because position: relative makes the card its containing block.
Stretch between two sides
.toolbar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
}When width is auto, setting both left and right stretches the box across the viewport.
Line up with an anchor
.button {
anchor-name: --button;
}
.menu {
position: absolute;
position-anchor: --button;
right: anchor(right);
top: anchor(bottom);
}anchor(right) resolves to the right edge of the anchor element, so the menu's right edge lines up with the button.
Common pitfalls
- Nothing happens on static elementsright only applies to positioned elements. With the default position: static it is ignored.
- right is dropped when left is set on relativeIf a relatively positioned element sets both left and right, one of them is ignored. In left-to-right text, that is right.
- right does not follow text directionright is always the physical right side. For layouts that should flip in right-to-left languages, use inset-inline-end instead.