CSS position

Demo

The CSS position property is used in positioning an element. It can be used in conjunction with the top, right, bottom, and left properties to position an element where you want it.

Also see the float property.

Syntax

position: <value>

Possible Values

static
The element flows as normal. The left and top properties don't take effect.
relative
The element is offset relative to it's normal position in the flow.
absolute
The element is positioned based on it's containing block. The element is taken out of the normal flow. Any subsequent elements will not be impacted — they will appear where they normally would even if the previous element was not offset.
fixed
Similar to absolute, but also doesn't move when scrolled.

In addition, all CSS properties also accept the following CSS-wide keyword values as the sole component of their property value:

initial
Represents the value specified as the property's initial value.
inherit
Represents the computed value of the property on the element's parent.
unset
This value acts as either inherit or initial, depending on whether the property is inherited or not. In other words, it sets all properties to their parent value if they are inheritable or to their initial value if not inheritable.

Specifications

Initial Value
static
Applies To
All elements except for generated content.
Inherited?
No
Media
Visual

Example Code

div {
  position: fixed;
  top: 20px;
  left: 50px;
  }