CSS right Property
Description
The right property controls an element's horizontal offset when that element is participating in CSS positioning. It determines how the element should be offset from the right edge of its containing block, but it does nothing for elements that remain in the normal (static) flow; to take effect it must be used on an element whose positioning is enabled via the position property. Conceptually, right is one side of the pair of horizontal offset controls and is used whenever you need to anchor or nudge an element relative to the right boundary of its reference box.
How the offset created by right is applied depends on the element’s positioning mode. For example, when an element is positioned relatively it is visually shifted while its original document slot is preserved; when it is positioned absolutely or fixed the element is removed from normal flow and located with respect to the appropriate containing block (often the nearest positioned ancestor or the viewport). The final placement also depends on the other offset properties (such as left) or shorthands like inset, which together determine how the box edges relate to the reference box.
In practical layout work, right interacts with other layout mechanisms and context-forming features. Transforms, stacking contexts and certain layout conditions can change which box acts as the reference or can alter coordinate systems, so a transformed ancestor or other layout effects may change how right resolves; see transform for details on one common source of such changes. Because right operates in the positioning layer, it’s commonly used for overlays, tooltips, fixed UI controls, and precise alignment of absolutely-positioned elements, and it should be considered alongside document direction and any logical offset shorthands when aiming for internationalized layouts.
Definition
- Initial value
- auto
- Applies to
- Positioned elements
- Inherited
- No
- Computed value
- If specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, 'auto'.
- Animatable
- Yes
- JavaScript syntax
- object.style.right
Interactive Demo
Syntax
right: auto | <length> | <percentage>
Values
- <length>Floating-point number, followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px).
- <percentage>Integer, followed by a percent sign (%). The value is a percentage of the height of the parent object.
- autoDefault position, according to the regular HTML layout of the page.
Example
Browser Support
The following information will show you the current browser support for the CSS 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
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
