Position: absolute means that the element is taken out of the normal flow of the document and is completely isolated from what comes before and after; that is why you can use it to layer over something else. So as far as the <p>paragraph two</p> is concerned, the span tag doesn't exist so the p tag will be as high in <div class="content"> as it can go.
When you remove the position: absolute the <span class="number">4</span> creates another character height plus any default top or bottom margin in the normal flow of the document, pushing down the <p>paragraph two</p> to a lower position.
Edit:- if you add background colors temporarily you will see what is happening; try it with and then without position: absolute in the .number style.
Code:
<style type="text/css">
#chapter {
margin-left:40px;
}
p {
margin-bottom: 2em;
}
.comment { background-color: pink;
position: relative;
left: -25px;
}
.number {
position: absolute; background-color: skyblue;
}
</style>
</head>
<body>
<div id="chapter">
<p>
paragraph one
</p>
<div class="comment"><span class="number">4</span></div>
<p style="background-color: green">
paragraph two
</p>
</div>
Last edited by Wickham; 16 Jan 2008 at 01:11 AM.
Code downloaded to my PC will be deleted in due course.
WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.