absolute positioning in FF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • somelongusername
    New Member
    • Jun 2008
    • 7

    #1

    absolute positioning in FF

    Hi all,

    I'm trying to understand how absolute positioning works, and I came across a weird thing in FF. if I use the code below, then the DIV tags are overlayed on top of each other, but the P tags aren't i.e. Text P is display and then Text p on the next line.

    But if I switch the position of the P tags with DIV i.e. display div first and then P, than BOTH tags are overlayed.

    I'm just curious to know what exactly is suppose to happen (I assume we should get the same behavior in both cases.

    Thanks a lot of the help!!!



    [HTML]
    <html>
    <head>
    <style type="text/css">
    div
    {
    margin-top: 1em;
    position:absolu te;
    left:100px;
    top:150px
    }

    p
    {
    position:absolu te;
    left:10px;
    top:50px
    display: block;
    }

    </style>
    </head>

    <body>

    <p>Text P</p>
    <p>Text p</p>

    <div>Text D</div>
    <div>Text D</div>

    <!--
    Both are overlayed

    <div>Text D</div>
    <div>Text D</div>

    <p>Text P</p>
    <p>Text p</p>
    -->
    </body>


    </html>

    [/HTML]
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    It isn't Firefox doing anything wrong. You aren't using a doctype. Therefore, FF goes into quirks mode and uses a box model from the middle-ages. If you aren't aware of doctypes, see the article under Howtos at the top.

    Comment

    • somelongusername
      New Member
      • Jun 2008
      • 7

      #3
      Thanks drhowarddrfine, that fixed it! But can you please elaborate why I get different behavior in the two situations?

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        HTML4.01 is based upon a proper box model. Quirks mode uses a quirky box model that is not based on HTML4.01. So we tell the browser to use html4.01 rules. And that's when it works as expected.

        Comment

        Working...