var list = []; document.querySelectorAll("body *") .forEach(function(elem){ if(elem.getBoundingClientRect().width > document.body.getBoundingClientRect().width){ list.push(elem.outerHTML.split('>')[0] + '>'); } }); confirm( "these elements are wider than the viewport:\n\n " + list.join("\n") )