Second iframe to take up available height


Suppose I have two iframes on a page with 100% height. Consider the iframes as header iframe and footer iframe. Both take up 100% width. The header iframe takes up 80px height and the footer iframe should take up rest of the available height i.e. 100%-80px height.

What is the best way to do this?

Paul, your example code does indeed demonstrate more or less what I was trying to do. Yes, I would like to avoid iframes, but in this situation where I don’t want to use any javascript or frames - iframes seems a better choice. I read somewhere it’s more appropriate to use objects instead - I’ll look into that. :slight_smile:

Why are you even thinking about using iframes?


As Stevie said but assuming you have no other choice but to use iframes then you could possibly do something like this:

Just use an iframe in the header section and it should work but not sure how stable it will be.

You could just absolutely position them if IE6 support isn’t required.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" xml:lang="en" >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<title>Iframe to rest of page height&#37;</title>
<style type="text/css">
body {
    font-family: verdana;
    font-size: 1em;
    background: #bef2a5;
html, body {
html {overflow:auto}
iframe, #main {
#myFrame1 {height:80px;}
#myFrame2 {height:100%;}
#main {
* html #main, * html iframe {
<iframe id="myFrame1" name="myFrame1" frameborder="0" src=""></iframe>
<div id="main">
    <iframe id="myFrame2" name="myFrame2" frameborder="0" src=""></iframe>

However, if possible iframes should be avoided but if you have to use them then keep them simple for best results.

I haven’t read Paul’s reply yet, but just want to clarify: by header Iframe I don’t mean it as an actual “header”. Only in the sense that it’s on the top - and same with footer, that it’s below the other one.

This is for a “website loading” kind of page. The top iframe shows loading related messages while the bottom one shows the website, say for example.

Anyway, I’ll check out what Paul suggested.