Kevin Aartsen Kevin Aartsen - 5 months ago 12
HTML Question

How to make a div cover the whole screen

I have a question.

I got this so far:
enter image description here

I basically want the highlighted div to cover your device screen no matter how big the device screen is. now i see 2 different divs when i open this on my phone. i only want to see the one that is highlighted. How do I achieve this?

Thanks in advance,


You could use viewport height as your height value:

.main {
    height: 100vh;
    background-color: green;
<div class="main">

Using height: 100vh means the element in question always be 100% height of the viewport a user / devie has.

More info: