Navigation Menu
Alphabetical Listing
Site Contents

Site FAQ
About JSS
JavaScript Forum
JavaScript Tutorial
Friends of JSS

Link to Us
JavaScript Help
Contribute a script
Technology Jobs

Become a Partner

Internet.commerce

Be a Commerce Partner


Developer Channel

FlashKit.com
JavaScriptSource
Developer Jobs
ScriptSearch
WebDeveloper.com
Webreference
HTMLGoodies
HTML5 Dev Center
Developer.com
jGuru.com
PHPBuilder

Great Sites

DocJavaScript.com
dhtml.com
The Freebie Directory
TheFreeSite.com

Browse Doc JS's Tips!


Hiermenus Central


Promotions

Free Announcements


Social Bookmark

General

A problem sometimes faced by Web developers is trying to get two (or more) columns in a multi-column layout to be the same height when the content is variable. Rather than using an arbitrary hardcoded value, the heights can be equalized (to the tallest one) with this script.


Notes

Assuming two columns in div tags with ids of "leftside" and "rightside" this script will set the height of the shorter to the height of the taller one. The page must be in standards compliant mode with a valid doctype or IE will mess it up in quirks mode. Just change the ids in the script to match the ones on your page.

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: columnsEqualHeight.js


Head

Paste this code into the HEAD section of your HTML document.


User Comments

Add a comment, suggestion, or correction
[For questions about usage, consult the Notes tab above or visit the JavaScript forum. Do not include more than two (2) lines of code in your comments. If you have suggestions or corrections, you can submit them to us.]

    
   
       
[optional]
 
[optional]

   

Comments feed Comment Feed RSS 2.0

1. From: William
Flexible Layouts
10/04/2007 02:50:43

How do I apply this code to a flexible Layout. After Testing it on one of my websites, I found that the script does not recalculate the height of the columns after resizing the window.

2. From: Lee (Admin)
11/06/2007 12:02:45

You might want to try this one.


Do you write JavaScripts?
If you do, why not submit them to us?
We'll give you credit and a link back to your Web site.