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.


1 Answer

Matthew Lang
Matthew Lang
13,483 Points

I'm not too sure what you're asking exactly, however hopefully this can clear up some confusion.

An element with absolute positioning will be positioned relative to any parent/grandparent that has a relative positioning. I believe by default the 'html' tag has relative positioning by default however I am not sure...

So if you have a div, and it had relative positioning, then an image inside the div with absolute positioning, the image would be positioned relative to the div container. If the div container did not have relative positioning, the image would be positioned relative to the next parent/grandparent that has relative positioning.

Apologies, but that probably isn't explained too well. Here's a JSFiddle: https://jsfiddle.net/sL12cten/