Click here to Skip to main content
15,847,653 members
Articles / Programming Languages / Javascript

Set height of a div to full screen

Rate me:
Please Sign up or sign in to vote.
4.71/5 (7 votes)
25 Dec 2011CPOL 73.1K   15   7
How to set the height of a div to full screen.

Here is how to set the height of a div to full screen:

min-height:expression( document.body.clientHeight +’px’);

If your website is jQuery enabled, the same can be achieved by:


NOTE: The prime reason behind posting this trick was that 'height:100%;' does not work with IE 8 browser. So if any alternative is posted, I would request the authors to test it in IE 8 compatibility mode in IE 9.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Web Developer
India India
Software developer by profession, working for a service and product based organisation in India.

Career graph:
Software Programmer since 2002.
Web Developer in ASP.NET since 2004.

I love reading the blogs and articles of technology experts. I love codeproject and stackoverflow .

I love to share knowledge and help the programmers. I appreciate if some body corrects my code or my concepts which helps me learn.

Comments and Discussions

GeneralRe: Direct from Microsoft website ("About Dynamic Properties" ur... Pin
gladtobegrey14-Nov-11 4:02
gladtobegrey14-Nov-11 4:02 
GeneralThe prime reason behind posting this trick was that 'height:... Pin
bbirajdar1-Dec-11 4:45
bbirajdar1-Dec-11 4:45 
GeneralInsufficient info and it doesn't work Pin
joekecalo21-Nov-11 22:43
joekecalo21-Nov-11 22:43 
Insufficient info and it doesn't work
Generalcan you tell how can we get the height of screen when we hav... Pin
spydeehunk7-Nov-11 17:48
spydeehunk7-Nov-11 17:48 
GeneralRe: Yes. The javascript will get the height of the client browse... Pin
bbirajdar7-Nov-11 23:35
bbirajdar7-Nov-11 23:35 
GeneralNot really, no. CSS expressions were unique to IE, and were... Pin
gladtobegrey7-Nov-11 13:05
gladtobegrey7-Nov-11 13:05 
GeneralRe: CSS expressions are still valid. I have tested it in IE 8 an... Pin
bbirajdar14-Nov-11 3:50
bbirajdar14-Nov-11 3:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.