July 16, 2024 Get the screen width and height as pixel values using a simple CSS code. Unitless values so you can easily use them inside any formula Updates on screen resize (No need for JavaScript) :root { --w: calc(100vw/1px); /* screen width */ --h: calc(100vh/1px); /* screen height */ /* The result is an integer without a unit! */ } Resize the demo below to see how the values update in real-ti

