calculate the width of a div in javascipt code example Example: javascript get width of a div document.getElementById("mydiv").offsetWidth