Easy Tutorial
❮ Jsref Sin Prop Area Protocol ❯

Style position Property


Definition and Usage

The position property sets or returns the type of positioning method used for an element (static, relative, absolute, or fixed).

Syntax

Setting the position property:

Returning the position property:

Value Description
static Default. An element with position: static; is always positioned according to the normal flow of the page (ignores any top, bottom, left, or right declarations).
absolute An element with position: absolute; is positioned relative to the first positioned (non-static) ancestor element. This element's position can be specified with "left", "top", "right", and "bottom" properties.
fixed An element with position: fixed; is positioned relative to the browser window. This element's position can be specified with "left", "top", "right", and "bottom" properties. The element remains in the same place even if the window is scrolled. Works in IE7 (strict mode).
relative An element with position: relative; is positioned relative to its normal position, so "left:20" adds 20 pixels to the element's LEFT position.
inherit The value of the position property is inherited from the parent element.

Browser Support

All major browsers support the position property.

Note: IE7 and earlier versions do not support the "inherit" value. IE8 requires a !DOCTYPE to support "inherit". IE9 supports "inherit".


Example

Change the element's position from static (default) to absolute:

❮ Jsref Sin Prop Area Protocol ❯