Relative vs. Absolute Positioning
Learn the difference between relative and absolute positioning with an example.
CSS has a position
property, and its values can be set to static
, relative
, absolute
, and fixed
.
When the static
property is the default behavior, we can’t nudge elements from their usual flow. In contrast, when its static property is set to relative
, we can nudge the elements from the normal flow, using the top
, right
, bottom
, and left
CSS properties by giving them negative and positive values. These values are usually expressed in pixels, for example:
div{
position: relative;
bottom: -20px;
}
Get hands-on with 1400+ tech skills courses.