Click here to Skip to main content
Click here to Skip to main content

Set height of a div to full screen

, 25 Dec 2011
Rate this:
Please Sign up or sign in to vote.
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:
 
$('#yourHtmlElementId').attr('height',$(window).height());
 
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.

License

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

About the Author

aspnet -i
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.
 
Interests:
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... PinmemberGladToBeGrey14-Nov-11 3:02 
GeneralThe prime reason behind posting this trick was that 'height:... PinmemberB Birajdar1-Dec-11 3:45 
GeneralInsufficient info and it doesn't work Pinmemberjoekecalo21-Nov-11 21:43 
Generalcan you tell how can we get the height of screen when we hav... Pinmemberspydeehunk7-Nov-11 16:48 
GeneralRe: Yes. The javascript will get the height of the client browse... PinmemberB Birajdar7-Nov-11 22:35 
GeneralNot really, no. CSS expressions were unique to IE, and were... PinmemberGladToBeGrey7-Nov-11 12:05 
GeneralRe: CSS expressions are still valid. I have tested it in IE 8 an... PinmemberB Birajdar14-Nov-11 2:50 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 25 Dec 2011
Article Copyright 2011 by aspnet -i
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid