Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS right property

CSS right property

Example

Set the image's right edge 5 pixels to the left of its containing element's right edge:

img

{

position:absolute;

right:5px;

}

Try it »


Property definition and usage

For static elements, it is auto; for length values, the corresponding absolute length; for percentage values, the specified value; otherwise it is auto. For relatively positioned elements, the computed value of left is always equal to that of right.

The right property specifies the right edge of an element. It defines the offset between the right margin edge of a positioned element and the right edge of its containing block.

Note: If the "position" property is "static", setting the "right" property has no effect.

Default value: auto
Inherited: no
Version: CSS2
JavaScript syntax: object.style.right="50px"

Browser support

The numbers in the table indicate the first browser version that supports this property.

property
right 1.0 5.5 1.0 1.0 5.0

Attribute values

Value Description
auto Default. The right edge position is calculated by the browser.
% Sets the right position as a percentage of the containing element. Negative values are allowed.
length Sets the right position of the element using units such as px, cm, etc. Negative values are allowed.
inherit Specifies that the right property should be inherited from the parent element.

Related Articles

CSS Tutorial: CSS Positioning