DEV Community

Discussion on: A painless guide to understanding CSS positioning

Collapse
 
alohci profile image
Nicholas Stimpson

"[position:absolute] If there is no element with a position property value the element will be positioned relative to the html or viewport element."

Common mistake, but no. If there is no positioned ancestor element, the element will be positioned relative to the Initial Containing Block. You can think of the initial containing block as the container of the html element, not the html element itself. The Initial Containing Block in located at (0, 0) of the canvas, and has the height and width of the viewport. So different from the viewport because the viewport moves over the canvas and so isn't necessarily at (0, 0).

Collapse
 
peterlunch profile image
Peter

Thanks for the clarification Nick.