DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Roy has posted 10 posts at DZone. View Full User Profile

Making Columns Render With Equal Height

  • submit to reddit
        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.

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.  For longer articles and discussion <a href=""> visit my home site... ERT</a>
<script type="text/javascript">
function setH()
   var maxH = Math.max(document.getElementById('leftside').offsetHeight,document.getElementById('rightside').offsetHeight);