The following code yields 15 for the offsetHeight in IE and Chrome, and in most installations of FireFox, but I’ve come across a few cases (3 computers, so far) where FF yields 14. I uninstalled and reinstalled FF and still got the same results.
<html>
<head>
<style type="text/css">
body {
font-size: 12px;
}
</style>
</head>
<body>
<span id="abc">ABC</span>
<script>
console.log(document.getElementById('abc').offsetHeight);
</script>
</body>
</html>
I’ve compared the actual pixel height of the text, and it’s the same between the browsers. If I put a border around the text, it reveals that Chrome is leaving three pixels between the top of the text and the top border (and the same on the bottom), whereas FF leaves two pixels at the top and three at the bottom. Any ideas?
Use a strict doctype, and do a css reset: