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

CSS CSS Layout Basics Positioning Page Content Positioning Elements Relative to Other Elements

Is relative positioning only meant for parent containers?

I just want to verify my understanding. From what I've gathered so far, absolute gives the element and absolute position that is relative to the first parent container that has a position of relative.

So with that being said. Is there ever a scenario where we'd use relative on the element itself, or is its only job to tell absolute positioning where to position the element in relation to?

1 Answer

Steven Parker
Steven Parker
229,968 Points

You can use relative positioning on individual elements.

Besides establishing a positioning context for any descendants, with this property set you can apply offsets (such as "top" and "left") to cause the element to appear in a different place than it would normally.

Note that the position of other elements around it will not be affected by this. They will still behave as if the relative-positioned element was in its default location.


span {
  position: relative;
  left: 5em;