Full screen sections are everywhere in modern web design.
You’ll see them in:
- Landing Pages
- Hero Sections
- Portfolio Websites
- SaaS Homepages
- App Introductions
If you’ve ever wondered how developers make a section take up the entire screen height, the good news is that modern CSS makes it very simple.
In this tutorial, you’ll learn how to create a full screen section using CSS, including practical examples, common mistakes, and responsive techniques used in real projects.
What is a Full Screen Section?
A full screen section takes up the entire visible height of the browser window.
In CSS, this is usually done using:
|
1 |
height: 100vh; |
The vh unit stands for:
viewport height
So:
|
1 |
100vh |
means:
100% of the browser screen height
Basic Full Screen Section Example
HTML
|
1 2 3 4 |
<section class="hero"> <h1>Welcome to My Website</h1> <p>Create modern full screen layouts with CSS.</p> </section> |
CSS
|
1 2 3 4 5 6 7 8 9 10 |
.hero { height: 100vh; background: #222; color: white; display: flex; justify-content: center; align-items: center; flex-direction: column; } |
Why Developers Use Flexbox Here
You’ll notice this example uses Flexbox.
That’s because Flexbox makes it much easier to:
- Center content
- Align elements vertically
- Create responsive layouts
Without Flexbox, vertically centering content used to require awkward CSS hacks.
Result
This creates a full screen hero section where the content stays perfectly centered both horizontally and vertically.
This layout is extremely common in modern websites.
How 100vh Works
A lot of beginners get confused by viewport units.
Here’s the simple idea:
| Unit | Meaning |
|---|---|
| vh | viewport height |
| vw | viewport width |
Example:
|
1 |
height: 50vh; |
This means:
50% of the screen height
Full Screen Background Image Section
This is one of the most common real-world use cases.
CSS
|
1 2 3 4 5 6 7 8 9 10 11 |
.hero { height: 100vh; background-image: url("hero.jpg"); background-size: cover; background-position: center; display: flex; justify-content: center; align-items: center; } |
Why background-size: cover Matters
Without this:
|
1 |
background-size: cover; |
your image may:
- Stretch
- Repeat
- Look distorted
Most developers use cover for hero sections because it keeps the image visually balanced.
Responsive Full Screen Sections
In real projects, mobile responsiveness matters a lot.
Here’s a simple responsive setup:
|
1 2 3 4 |
.hero { min-height: 100vh; padding: 40px 20px; } |
Using:
|
1 2 3 4 5 6 7 8 9 10 11 |
min-height: 100vh; <pre> is often safer than fixed heights because the content can still grow naturally if needed. <h2>Common Mistakes Developers Make</h2> <h3>1. Using Fixed Heights</h3> Avoid this: <pre class="lang:css"> height: 800px; |
Fixed heights can break layouts on smaller devices.
Viewport units are much more responsive.
2. Forgetting Mobile Issues with 100vh
Some mobile browsers handle 100vh differently because of the address bar.
Modern CSS now supports:
|
1 |
height: 100dvh; |
dvh stands for:
dynamic viewport height
This works better on modern mobile browsers.
Better Mobile-Friendly Version
|
1 2 3 |
.hero { min-height: 100dvh; } |
Many modern developers now prefer dvh over vh.
Real Project Use Cases
Full screen sections are commonly used for:
- Hero banners
- Landing page intros
- Product showcases
- App download sections
- Portfolio websites
If you inspect modern SaaS websites, you’ll see this layout pattern almost everywhere.
Full Screen Section with Overlay
Here’s a more realistic design pattern.
HTML
|
1 2 3 4 5 |
<section class="hero"> <div class="overlay"> <h1>Build Better Websites</h1> </div> </section> |
CSS
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
.hero { height: 100vh; background: url("bg.jpg") center/cover no-repeat; display: flex; justify-content: center; align-items: center; } .overlay { background: rgba(0,0,0,0.5); color: white; padding: 40px; } |
This creates the dark overlay effect commonly used in hero sections.
Full Screen Section vs Full Width Section
Many beginners confuse these two.
| Layout | Meaning |
|---|---|
| Full screen | Takes full screen height |
| Full width | Takes full screen width |
Most hero sections use both.
Browser Support
Viewport units like:
- vh
- vw
- dvh
are supported in all modern browsers.
Which Method Should You Use?
For most modern projects:
✅ Recommended:
|
1 |
min-height: 100dvh; |
Fallback option:
|
1 |
min-height: 100vh; |
Final Thoughts
Creating a full screen section using CSS is much easier today than it used to be.
For most layouts:
- Use Flexbox for alignment
- Use 100vh or 100dvh for height
- Avoid fixed heights
Once you understand viewport units, building modern landing pages and hero sections becomes much more straightforward.
Frequently Asked Questions (FAQs)
Q1. How do I make a section full screen in CSS?
Use:
|
1 |
height: 100vh; |
or:
|
1 |
min-height: 100dvh; |
Q2. What does 100vh mean in CSS?
It means:
100% of the browser viewport height
Q1. Should I use vh or dvh?
For modern mobile-friendly layouts, dvh is usually better.
