CSS right ιδιότητα

Definition and usage

The 'right' property specifies the right edge of the element. This property defines the offset between the right outer margin boundary of the positioned element and the right boundary of the containing block.

Note:If the value of the 'position' attribute is 'static', setting the 'right' attribute will have no effect.

Description

For 'static' elements, it is 'auto'; for length values, it is the corresponding absolute length; for percentage values, it is the specified value; otherwise, it is 'auto'.

For relatively defined elements, the calculated value of 'left' is always equal to 'right'.

See also:

CSS Tutorial:CSS Positioning

HTML DOM Reference Manual:right property

Example

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

img
  {
  position:absolute;
  right:5px;
  }

Try it yourself

CSS syntax

right: auto|length|initial|inherit;

Attribute value

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

Technical details

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

More examples

Set the right edge of an image using fixed values
This example demonstrates how to set the right edge of an image using fixed values.
Set the right edge of an image using percentage
This example demonstrates how to set the right edge of an image using percentage values.

Browser support

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

Chrome IE / Edge Firefox Safari Opera
1.0 5.5 1.0 1.0 5.0