- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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

- Related Articles
- Why doesn't height: 100% work to expand divs to the screen height?
- How to make the web page height to fit screen height with HTML?
- HTML Screen height Property
- How to get the Width and Height of the screen in JavaScript?
- How to Make a DIV 100% of the Window Height using CSS
- How can I get android device screen height, width?
- How to make the main content div fill height of screen with CSS and HTML
- Finding the height based on width and screen size ratio (width:height) in JavaScript
- Python Program to Read Height in Centimeters and convert the Height to Feet and Inches
- Why cannot I use iframe absolute positioning to set height/width
- Why does one get hurt on jumping from a great height to the floor?
- What is the difference between height and line-height?
- What is the ratio of the height of an image to the height of an object known as?
- Program to find a matrix for each condominium's height is increased to the maximum possible height in Python?
- A ball is thrown upwards and it goes to the height 100 m and comes down: What is the net displacement?
- A ball is thrown upwards and it goes to the height 100 m and comes down. What is the net distance?

Advertisements