CSS Property right

right defines the offset to the right outer margin edge of a positioned element.


Initial value auto
Inherited No.
Version CSS2
JavaScript syntax object.style.right="40px"
Applies to Positioned elements (not static positioned).

CSS Syntax

right: length | percentage | auto | inherit 

Property Values

The property values are listed in the following table.

auto Default value. The browser does the calculation.
length Set width in px, cm, etc.
% Set width in percent of the containing element
inherit Inherit the width property from the parent element

Browser compatibility

right Yes Yes Yes Yes Yes


An example showing how to use right CSS property.

div,p,em {<!-- w  w  w .jav a2 s  .  c om-->
  margin: 10px;
  padding: 10px;
  background-color: white;
  border-left: 1px solid gray;
  border-right: 2px solid black;
  border-top: 1px solid gray;
  border-bottom: 2px solid black;

* .pos {
  position: relative;
  right: -100px;


<div class="relative"> 
    <p class="pos">Positioned</p> 

Click to view the demo