treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Why use absolute with relative?

  • Why does one need to use a relative positioned div inorder to place an absolute positioned element. Why not just use padding and margins to place whatever you are placing?
  • Margin and padding are used to position objects that are still "in the flow" of the document. This means that their position will still affect other page elements on the page. By using absolute positioning, it takes that element "out of the flow" so that it can be placed anywhere regardless of where other object lay.