Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / Javascript

Set height of a div to full screen

4.71/5 (7 votes)
25 Dec 2011CPOL 74.7K  
How to set the height of a div to full screen.

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


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


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

JavaScript
$('#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)