Style right Property

Style Object Reference Style Object


Set the right position of a <div> element:

document.getElementById("myDIV").style.right = "100px";
Try it Yourself »

Definition and Usage

The right property sets or returns the right position of a positioned element.

This property specifies the right position of the element including padding, scrollbar, border and margin.

Tip: A positioned element is an element with the position property set to: relative, absolute, or fixed.

Tip: To set or return the left position of a positioned element, use the left property.

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The right property is supported in all major browsers.


Return the right property:

Set the right property:"auto|length|%|initial|inherit"

Property Values

Value Description
auto Lets the browser set the right position. This is default
length Defines the right position in length units. Negative values are allowed
% Sets the right position in % of the width of the parent element
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

Technical Details

Default Value: auto
Return Value: A String, representing the right position of a positioned element
CSS Version CSS2

More Examples


Using negative values - Set the right position of a <div> element:

document.getElementById("myDiv").style.right = "-100px";
Try it Yourself »


Return the right position of a <div> element:

Try it Yourself »

Related Pages

CSS tutorial: CSS Positioning

CSS reference: right property

Style Object Reference Style Object