Solution:
Use of absolute positioning. Specify the top style to be the height of your header and set bottom to 0.
Sample:
<!DOCTYPE html>
<html> <head> <title>Auto-expand body height</title> <style type="text/css"> body { height: 100%; margin: 0;position: relative;
} html { height: 100%; } html * {
box-sizing: border-box;-webkit-box-sizing: border-box; -moz-box-sizing: border-box; } </style> </head> <body> <div style="height: 200px; border: 1px solid blue;"> </div> <div style="border: 1px solid red; position: absolute; top: 200px; bottom: 0; width: 100%;"> </div> </body> </html>
[Updated June, 2014] Or if you want a fixed footer too:
<!DOCTYPE html> <html> <head> <title>Auto Expand</title> <style type="text/css"> body { height: 100%; margin: 0; min-height: 450px; position: relative; } html { height: 100%; } html * { box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; } </style> </head> <body> <div style="height: 200px; border: 1px solid blue;"> </div> <div style="border: 1px solid red; position: absolute; top: 200px; bottom: 100px; width: 100%;"> </div> <div style="height: 100px; border: 1px solid green; position: absolute; bottom: 0; width: 100%;"> </div> </body> </html>