Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


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/