right

Description

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

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

Syntax and Property Values


right: length | percentage | auto | inherit 

The property values are listed in the following table.

ValueDescription
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

Example


<!DOCTYPE HTML>
<html>
<head>
<style>
div,p,em {<!--from  www  .  ja v a  2  s  . c o m-->
  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;
}


</style>
</head>

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

Click to view the demo

The code above generates the following result.

right




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference