What are the rules for getting the correct offsetHeight of a div? This gives the correct offsetHeight of the contens: <div id="container" style="position:relative;float:left><div id="contens" style="position:relative;float:left;">Some text</div></div> But this will not: <div id="container" style="position:relative;float:left><div id="contens">Some text</div></div>.
Both the codes seem to give the same result. In which context do you expect to see a difference? Is it for a middle paragraph?