codes = document.getElementsByTagName("div"); for (i = 0; i < codes.length; i++) { if (codes[i].className != "code") continue; codes[i].style.width = document.width / 2; }