XML technologies / CSS / Advanced websites with CSS / CSS property reference / right

(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)

The property right describes the distance between the right edge of an element positioned with absolute (including padding, border and margin) and the right edge of the nearest ancestor whose property position has a value other than static. (Note: The CSS2 specification incorrectly states that padding, border and margin should be disregarded here. The CSS Working Group has already documented this error in the CSS2 errata.) If no such ancestor exists, the reference is the right edge of body.

For elements positioned with relative, the property right shifts the right edge relative to the element’s position without CSS positioning. A setting of 10px moves the element’s right edge 10 pixels to the left, while -10px moves it the same distance to the right.

Inherited: no

See also: position, bottom, left and top

Values

A CSS measurement, a percentage or the constant auto. Percentages are based on the parent element’s width. The constant auto instructs the browser to determine the right edge’s position automatically, taking other variables such as size and position into account.

Default value: auto

CSS version: 2

Works in all CSS-capable browsers, including Internet Explorer 4 and later, Netscape 4 and later, and Mozilla.

Example

The following style rule positions the element with ID menue directly against the page’s right edge (the element is directly inside body):

#menue {
 position: absolute;
 right: 0;
 width: 100px;
 height: 200px;
}

  

 

 

 

back to top