![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Why doesn't height: 100% work to expand divs to the screen height?
To set the height to 100% for expanding divs to the screen height, set the entire document to −
html { height: 100%; }
First, we have set both the html and body to −
html, body { height: 100%; }
The div is set with height and min-height property −
#mydiv { min-height: 100% !important; height: 100%; border: 2px solid yellow; width: 200px; background: orange; }
Under the <body>, we have our div for which we set the CSS property above −
<div id=mydiv> Demo Text </div>
Example
Let us now see the complete example −
<html> <head> <title>Example</title> <style> html, body { height: 100%; } #mydiv { min-height: 100% !important; height: 100%; border: 2px solid yellow; width: 200px; background: orange; } </style> </head> <body> <div id=mydiv> Demo Text </div> </body> </html>
Output
![](https://www.tutorialspoint.com/assets/questions/media/495676-1670231120.png)
Advertisements