Relative positioning
Relative positioning offsets an element from its normal position while preserving its space in normal document flow.
Web Design Playground, Second Edition
Relative positioning is a CSS layout technique that visually shifts an element from its normal position while preserving its place in normal document flow.
- How it is used
- Uses relative positioning to shift an element while retaining its space, or to establish a context for an absolute overlay.
- How deep it goes
- Works through offset directions and a visible gap, then applies a relative container in a portfolio overlay.
- Examples
- Shows a span shifted down by top: 3em and a portfolio container holding an absolutely positioned after-image.
- What you can do after
- Apply it via CSS to offset an element or set the positioning context for an absolute image overlay.
Read how Web Design Playground, Second Edition explains relative positioning →
CSS in Depth, Second Edition
Relative positioning is a CSS positioning mode that keeps an element in normal flow while allowing offsets and establishing a containing block for positioned descendants.
- How it is used
- Anchors absolutely positioned descendants while keeping the anchor in normal document flow.
- How deep it goes
- Explains offset behavior and containing blocks through worked menus, then connects positioning to stacking order without detailing browser layout internals.
- Examples
- Uses shifted inline-block elements, a click-operated dropdown, and a mobile navigation menu.
- What you can do after
- Build it from scratch: anchor an absolutely positioned dropdown to its toggle using CSS and a JavaScript-controlled open state.
Read how CSS in Depth, Second Edition explains relative positioning →
Tiny CSS Projects
Relative positioning offsets an element from its normal position while preserving its original space in the document flow.
- How it is used
- Establishes local positioning contexts and makes small visual adjustments in card layouts and typography.
- How deep it goes
- Explains parent-child positioning and directional offsets, while demonstrating layering through absolute positioning rather than detailing browser internals.
- Examples
- Demonstrates a virtual credit card overlay and a decorative drop cap adjusted within paragraph text.
- What you can do after
- Apply it via CSS to establish local positioning contexts or nudge elements within their normal layout.
Also covered in
What to know first
- viewportA viewport is the visible region of a browser or graphical interface in which a document or other content is displayed.
- normal flowNormal flow is the browser’s ordinary layout process, arranging elements according to document order and their formatting behavior without out-of-flow positioning.
- containing blockA CSS reference rectangle used to resolve certain descendant properties, including an element's dimensions and position.
Related concepts
- containing blockconfigures · A CSS reference rectangle used to resolve certain descendant properties, including an element's dimensions and position.
- offsetuses · An offset is a position or displacement measured relative to a reference point, such as within an ordered sequence, memory region, or layout.
- inset propertyuses · The CSS inset property is a shorthand property that sets an element's top, right, bottom, and left offsets.
- normal flowuses · Normal flow is the browser’s ordinary layout process, arranging elements according to document order and their formatting behavior without out-of-flow positioning.
- sticky positioningcontrasts with · Sticky positioning is a CSS positioning mode in which an element remains in normal document flow until a specified offset threshold is reached, then stays constrained within its containing block as scrolling continues.
Questions about relative positioning
What is relative positioning?
Relative positioning offsets an element from its normal position while preserving its space in normal document flow.
Which Manning books explain relative positioning?
Web Design Playground, Second Edition, CSS in Depth, Second Edition and Tiny CSS Projects.
What should I know before learning relative positioning?
Manning books that teach relative positioning usually introduce viewport, normal flow, containing block and CSS unit first.
What is the difference between relative positioning and sticky positioning?
Relative positioning offsets an element from its normal position while preserving its space in normal document flow. Sticky positioning is a CSS positioning mode in which an element remains in normal document flow until a specified offset threshold is reached, then stays constrained within its containing block as scrolling continues.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


