CSS CSS Layout Basics Positioning Page Content Create an Image Caption with Absolute Positioning

Positioning elements

In this video, the caption is positioned over the image with absolute positioning relative to the container holding the image. I'm confused as to why the container is given relative positioning rather than the image itself. Won't this cause issues if the container or image change size?

1 Answer

Steven Parker
Steven Parker
203,207 Points

The container is given a "relative" position setting, but no placement offsets are used. So the position of the container does not change, but the setting causes it to become the reference for any positioned child elements (instead of the window).