Instance
To locate the H2 element:
H2 { position:absolute;
left:100px; top:150px; }
Try it yourself.
Browser support
IE |
Firefox |
Chrome |
Safari |
Opera |
|
|
|
|
|
All major browsers support the Position property.
Note: The property value "Inherit" is not supported by any version of Internet Explorer (including IE8).
Definition and usage
The Position property specifies the positioning type of the element.
Description
This property defines the positioning mechanism used to create the element layout. Any element can be positioned, but an absolute or fixed element generates a block-level box, regardless of the type of the element itself. Relative positioning elements are offset relative to their default position in the normal flow.
Default value: |
Static |
Inheritance: |
No |
Version: |
CSS2 |
JavaScript Syntax: |
object. style.position= "Absolute" |
Possible values
value |
Description |
Absolute |
Creates an absolutely positioned element that is positioned relative to the first parent element other than the static anchor. The position of the element is defined by the "left", "Top", "right" and "bottom" attributes. |
Fixed |
Generates an absolutely positioned element that is positioned relative to the browser window. The position of the element is defined by the "left", "Top", "right" and "bottom" attributes. |
Relative |
Creates a relative positioned element, positioned relative to its normal position. Therefore, "left:20" adds 20 pixels to the left position of the element. |
Static |
The default value. No positioning, elements appear in the normal stream (ignoring top, bottom, left, right, or z-index declarations). |
Inherit |
Specifies that the value of the position property should be inherited from the parent element. |
Tiy instances
-
Positioning: Relative positioning
-
This example shows how to position a element relative to its normal position.
-
Positioning: Absolute Positioning
-
This example demonstrates how to use an absolute value to position an element.
-
Positioning: Fixed positioning
-
This example demonstrates how to position an element relative to a browser window.
-
Set the shape of an element
-
This example shows how to set the shape of an element. This element is clipped into this shape and is displayed.
-
Z-index
-
Z-index can be used after one element is placed on another element.
-
Z-index
The
-
elements in the above example have changed the Z-index.
Related pages
CSS Tutorial: CSS Positioning
HTML DOM Reference manual: Position properties