Is there a way to detect the true border, padding and margin of elements from Javascript code? If you look at the following code:
the style
property can get the styles that are assigned inline like
if you want to get the styles assigned in outer css file or element, try this:
var div = document.getElementById("target");
var style = div.currentStyle || window.getComputedStyle(div);
display("Current marginTop: " + style.marginTop);
if you are using jQuery, @vsync 's solution is fine.