Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
221,322 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).