Style position Property
The Style object
Definition and Usage
The position property sets or returns the type of positioning method used for an element (static, relative, absolute, or fixed).
Syntax
Set the position property:
Object.style.position="static|absolute|fixed|relative|inherit"
Return the position property:
Object.style.position
| Value | Description |
|---|---|
| static | Default. An element with a position of static is always in the position given by the page flow (a static element ignores any top, bottom, left, or right declarations). |
| absolute | An element with a position of absolute can be positioned at specified coordinates relative to the first positioned (non-static) ancestor element. The element's position can be specified with the "left", "top", "right", and "bottom" properties. |
| fixed | An element with a position of fixed can be positioned at specified coordinates relative to the browser window. The element's position can be specified with the "left", "top", "right", and "bottom" properties. The element stays in that position whether the window is scrolled or not. Works in IE7 (strict mode). |
| relative | An element with a position of relative can be positioned relative to its normal position, so "left:20" moves the element 20 pixels to the left of its normal 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 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".
Example
Example
Change an element's position from static (the default) to absolute:
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
Try it »
The Style object