function resize () { const baseFontSize = 16 const windowWidth = document.documentElement.clientWidth; const newVal = Math.round((windowWidth / 1920) * baseFontSize) document.documentElement.style.fontSize = `${newVal}px`; } window.addEventListener('resize', resize);