Code
Home<html> <head> <meta name="viewport" content="width=device-width, user-scalable=no"> </head> <body> <p id="width-txt"></p> <p id="height-txt"></p> </body> </html>
html {
box-sizing: border-box;
width: 100%;
height: 100%;
margin: 0;
border: 2px solid #FF0000;
}
const html = document.getElementsByTagName("html")[0];
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
document.getElementById("width-txt").textContent = `width = ${width}px`;
document.getElementById("height-txt").textContent = `height = ${height}px`;
html.style.width = width + "px";
html.style.height = height + "px";
}
window.addEventListener("resize", resize);
resize();
For Practice
Last updated: Oct 22, 2025