Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6983363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:24:34+00:00 2026-05-27T18:24:34+00:00

I need to position div s within div s, and I am getting crazy.

  • 0

I need to position divs within divs, and I am getting crazy. I’ve read many docs on the net, but I am still not clear about behavior of relative and absolute positioning when divs are embedded.

Someone came up with the following:

The best way I’ve found to understand absolute positioning is that
position:relative looks “downstream” to child elements and
position:absolute looks “upstream” to parent elements. That is, when
you tell an HTML element to be absolutely positioned, it’s going to
look “up” to its parent elements until it finds one that is set to
position:relative, and will position itself based on that. If it
doesn’t find one, it will position itself with respect to the
by default.

Is this correct for all browsers? Is this a complete explanation?

My issue is that I have several divs embedded in several divs. I need to position some child div within a parent div, with high precision (for example top 33, left 9). The parent div can be embedded in a grand-parent div, with high precision too, etc…

How does one solve this issue for all browsers? Should I create a super relative parent div from which the whole hierarchy of div should be positioned as absolute?

EDIT

From current answers, I have an extra question: does one have to explicitly declare a relative or absolute position in each div to make positioning work? In other words, if a div does not have a relative or absolute position, it is not taken into account when computing positions?

FOR THE RECORDS

The answer to the above question is yes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:24:34+00:00Added an answer on May 27, 2026 at 6:24 pm

    I find it a little easier to understand this way:

    If an item is position: relative, then any style settings for top, bottom, left, right positions are relative to where the item would have been in the normal layout flow. So:

    position: relative;
    top: 10px;
    

    pushes an item 10px down lower than it would have otherwise been in the normal HTML layout.

    If an item is position:absolute, then it is positioned relative to whatever the closest parent that is position: relative or position: absolute or relative to the body element if no parents meet that criteria. For example, if the immediate parent is `position: relative’ and the child is:

    position: absolute;
    top: 10px;
    left: 10px;
    

    Then, the object will be positioned down and to the right by 10px from the upper left corner of the parent. When an object is position: absolute, it is removed from the layout of the page and it does not affect the layout of any other objects (except it’s own children).

    As an example, if you want to position three images on top of one another in a container object (perhaps so you can cycle through them in a slideshow, you would do so with this CSS:

    .container {position: relative; height: 100px; width: 133px;}
    .container img {position: absolute; top: 0; left: 0;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not really sure what I need here but I want to position a
I need to position a div over an image with jQuery. I can create
I have some anchor elements, but they are in absolute position div and the
I need to get the position of the selected text within a content non-editable
I have to set background images (sprite pngs) within 3 divs. I need the
I need to position a div in the bottom left corner of a container
Ok, I have a few divs within a section of HTML. I need some
I need to position this update button on www.euroworker.no/order (you'll have to add an
Currently, in order to evaluate elist in Emacs, I need to position the cursor
I have an Panel control that I need to maintain position across postbacks. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.