var html = document.querySelector('html'); var rem = html.offsetWidth / 7.5; html.style.fontSize = rem + "px";