<p>I'm trying to make a two-column page using a div-based layout (no tables please!). Problem is, I can't grow the left div to match the height of the right one.  My right div typically has a lot of content.  </p>

<p>Here's a paired down example of my template to illustrate the problem.</p>

<pre><code>&lt;div style="float:left; width: 150px; border: 1px solid;"&gt;
  &lt;ul&gt;
    &lt;li&gt;nav1&lt;/li&gt;
    &lt;li&gt;nav2&lt;/li&gt;
    &lt;li&gt;nav3&lt;/li&gt;
    &lt;li&gt;nav4&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;div style="float:left; width: 250px"&gt;
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
....
&lt;/div&gt;
</code></pre>

[{'answer_id': 35711, 'author': 'DevelopingChris', 'author_id': 1220, 'author_profile': 'https://Stackoverflow.com/users/1220', 'pm_score': 3, 'selected': False, 'text': '<p>Your simplest answer lies in the next version of css (3), which currently no browser supports.</p>\n\n<p>For now you are relegated to calculating heights in javascript and setting them on the left side. </p>\n\n<p>If the navigation is so important to be positioned in such a way, run it along the top.</p>\n\n<p>you could also do a visual trick by moving the borders to the container and the bigger inner, and make it appear to be the same size.</p>\n\n<p>this makes it look the same, but it isn\'t.</p>\n\n<pre><code>&lt;div style="border-left:solid 1px black;border-bottom:solid 1px black;"&gt;\n  &lt;div style="float:left; width: 150px; border-top: 1px solid;"&gt;\n    &lt;ul&gt;\n     &lt;li&gt;nav1&lt;/li&gt;\n     &lt;li&gt;nav2&lt;/li&gt;\n     &lt;li&gt;nav3&lt;/li&gt;\n     &lt;li&gt;nav4&lt;/li&gt;\n    &lt;/ul&gt;\n &lt;/div&gt;\n &lt;div style="float:left; width: 250px; border:solid 1px black;border-bottom:0;"&gt;\n  Lorem ipsum dolor sit amet, consectetur adipisicing elit,\n  sed do eiusmod tempor incididunt ut labore et dolore magna\n  Lorem ipsum dolor sit amet, consectetur adipisicing elit,\n  ...\n &lt;/div&gt;\n &lt;div style="clear:both;" &gt;&lt;/div&gt;\n&lt;/div&gt;\n</code></pre>\n'}, {'answer_id': 35718, 'author': 'DevelopingChris', 'author_id': 1220, 'author_profile': 'https://Stackoverflow.com/users/1220', 'pm_score': 0, 'selected': False, 'text': "<p>@hoyhoy</p>\n\n<p>If a designer can make this work in html, then he can have this design. If he is a true master of web design, he will realize that this is a limitation of the media, as video is not possible in magazine ads.</p>\n\n<p>If he would like to simulate weight by giving the 2 columns equal importance, than change the borders, so that they appear to be of the same weight, and make the colors of the borders contrast to the font color of the columns.  </p>\n\n<p>But as for making the physical elements the same height, you can only do that with a table construct, or setting the heights, at this point in time. To simulate them appearing the same size, they don't have to be the same size.</p>\n"}, {'answer_id': 35880, 'author': 'Silviu Postavaru', 'author_id': 3718, 'author_profile': 'https://Stackoverflow.com/users/3718', 'pm_score': 2, 'selected': False, 'text': '<p>You can do it in jQuery really simple, but I am not sure JS should be used for such things. The best way is to do it with pure css.</p>\n\n<ol>\n<li><p>Take a look at <a href="http://www.alistapart.com/articles/fauxcolumns/" rel="nofollow noreferrer">faux columns</a> or even <a href="http://www.communitymx.com/content/article.cfm?cid=AFC58" rel="nofollow noreferrer">Fluid Faux Columns</a></p></li>\n<li><p>Also another technique(doesn\'t work on the beautiful IE6) is to position:relative the parent container. The child container(the nav list in your case) should be positioned absolute and forced to occupy the whole space with \'top:0; bottom:0;\'</p></li>\n</ol>\n'}, {'answer_id': 47403, 'author': 'Nathan Long', 'author_id': 4376, 'author_profile': 'https://Stackoverflow.com/users/4376', 'pm_score': 2, 'selected': False, 'text': "<p>This is one of those perfectly reasonable, simple things that CSS can't do. Faux Columns, as suggested by Silviu, is a hacky but functional workaround.\nIt would be lovely if someday there was a way to say</p>\n\n<pre>\ndiv.foo {\nheight: $(div.blah.height);\n}\n</pre>\n"}, {'answer_id': 53010, 'author': 'Bryan M.', 'author_id': 4636, 'author_profile': 'https://Stackoverflow.com/users/4636', 'pm_score': 3, 'selected': False, 'text': '<p>It can be done in CSS! Don\'t let people tell you otherwise.</p>\n\n<p>The easiest, most pain-free way to do it is to use the <a href="http://www.alistapart.com/articles/fauxcolumns/" rel="noreferrer">Faux Columns</a> method.</p>\n\n<p>However, if that solution doesn\'t work for you, you\'ll want to read up on <a href="http://www.positioniseverything.net/articles/onetruelayout/equalheight" rel="noreferrer">this technique</a>. But be warned, this is the kind of CSS hackery that will make you wake up in a cold sweat in the middle of the night.</p>\n\n<p>The gist of it is that you assign a large amount of padding to the bottom of the column, and a negative margin of the same size. Then you place your columns in a container that has <code>overflow: hidden</code> set. More or less the padding/margin values allow the box to keep expanding until it reaches the end of the wrapper (which is determined by the column with the most content), and any extra space generated by the padding is cut off as overflow. It doesn\'t make much sense, I know...</p>\n\n<pre><code>&lt;div id="wrapper"&gt;\n  &lt;div id="col1"&gt;Content&lt;/div&gt;\n  &lt;div id="col2"&gt;Longer Content&lt;/div&gt;\n&lt;/div&gt;\n\n#wrapper {\n  overflow: hidden;\n}\n\n#col1, #col2 {\n  padding-bottom: 9999px;\n  margin-bottom: -9999px;\n}\n</code></pre>\n\n<p>Be sure to read the entire article I linked to, there are a number of caveats and other implementation issues. It\'s not a pretty technique, but it works fairly well.</p>\n'}, {'answer_id': 54779, 'author': 'Bryan M.', 'author_id': 4636, 'author_profile': 'https://Stackoverflow.com/users/4636', 'pm_score': 0, 'selected': False, 'text': "<p>Come to think of it, I've never done it with a bottom border on the column. It's probably just overflowing, and getting cut off. You might want to have the bottom border come from a separate element that's part of the column content.</p>\n\n<p>Anyway, I know it's not a perfect magic bullet solution. You might just have to play with it, or hack around its shortcomings.</p>\n"}, {'answer_id': 396336, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>This <strong>can</strong> be done with css using background colors</p>\n\n<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;\n&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;\n&lt;head&gt;\n&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;\n&lt;title&gt;Untitled Document&lt;/title&gt;\n&lt;style type="text/css"&gt;\n* {\n    margin: 0;\n    padding: 0;\n}\nbody {\n    font-family: Arial, Helvetica, sans-serif;\n    background: #87ceeb;\n    font-size: 1.2em;\n}\n#container {\n    width:100%; /* any width including 100% will work */\n    color: inherit;\n    margin:0 auto; /* remove if 100% width */\n    background:#FFF;\n}\n#header {\n    width: 100%;\n    height: 160px;\n    background: #1e90ff;\n}\n#content {/* use for left sidebar, menu etc. */\n    background: #99C;\n    color: #000;\n    float: right;/* float left for right sidebar */\n    margin: 0 0 0 -200px; /* adjust margin if borders added */\n    width: 100%;\n }\n#content .wrapper {\n    background: #FFF;\n    margin: 0 0 0 200px;\n    overflow: hidden;\n    padding: 10px; /* optional, feel free to remove */\n}\n#sidebar {\n    background: #99C;\n    color: inherit;\n    float: left;\n    width: 180px;\n    padding: 10px;\n}\n.clearer {\n    height: 1px;\n    font-size: -1px;\n    clear: both;\n}\n\n/* content styles */\n#header h1 {\n    padding: 0 0 0 5px;\n}\n#menu p {\n    font-size: 1em;\n    font-weight: bold;\n    padding: 5px 0 5px 5px;\n}\n#footer {\n    clear: both;\n    border-top: 1px solid #1e90ff; \n    border-bottom: 10px solid #1e90ff;\n    text-align: center;\n    font-size: 50%;\n    font-weight: bold;\n}\n#footer p {\n    padding: 10px 0;\n} \n&lt;/style&gt;\n&lt;/head&gt;\n\n&lt;body&gt;\n\n\n&lt;div id="container"&gt;\n&lt;!--header and menu content goes here --&gt;\n\n&lt;div id="header"&gt;\n&lt;h1&gt;Header Goes Here&lt;/h1&gt;\n&lt;/div&gt;\n&lt;div id="content"&gt;\n&lt;div class="wrapper"&gt;\n&lt;!--main page content goes here --&gt;\n&lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus. Vivamus ut sem. Fusce aliquam nunc \n\nvitae purus. Aenean viverra malesuada libero. &lt;/p&gt;\n&lt;/div&gt;\n&lt;/div&gt;\n\n&lt;div id="sidebar"&gt;\n&lt;!--sidebar content, menu goes here --&gt;\n&lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus.&lt;/p&gt;\n&lt;/div&gt;\n\n&lt;div class="clearer"&gt;&lt;/div&gt;&lt;!--clears footer from content--&gt;\n&lt;!--footer content goes here --&gt;\n&lt;div id="footer"&gt;\n&lt;p&gt;Footer Info Here&lt;/p&gt;\n&lt;/div&gt;\n&lt;/div&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n</code></pre>\n'}, {'answer_id': 396350, 'author': 'Burak Erdem', 'author_id': 49380, 'author_profile': 'https://Stackoverflow.com/users/49380', 'pm_score': 0, 'selected': False, 'text': '<p>There is also a Javascript based solution. If you have jQuery, you can use the below plugin.</p>\n\n<pre><code>&lt;script type="text/javascript"&gt;\n// plugin\njQuery.fn.equalHeights=function() {\n    var maxHeight=0;\n\n    this.each(function(){\n        if (this.offsetHeight&gt;maxHeight) {maxHeight=this.offsetHeight;}\n    });\n\n    this.each(function(){\n        $(this).height(maxHeight + "px");\n        if (this.offsetHeight&gt;maxHeight) {\n            $(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");\n        }\n    });\n};\n\n// usage\n$(function() {\n    $(\'.column1, .column2, .column3\').equalHeights();\n});\n&lt;/script&gt;\n</code></pre>\n'}, {'answer_id': 594021, 'author': 'Stiropor', 'author_id': 67325, 'author_profile': 'https://Stackoverflow.com/users/67325', 'pm_score': 0, 'selected': False, 'text': '<p>I use this to align 2 columns with ID "center" and "right":</p>\n\n<pre><code>var c = $("#center");\nvar cp = parseInt(c.css("padding-top"), 10) + parseInt(c.css("padding-bottom"), 10) + parseInt(c.css("borderTopWidth"), 10) + parseInt(c.css("borderBottomWidth"), 10);\nvar r = $("#right");\nvar rp = parseInt(r.css("padding-top"), 10) + parseInt(r.css("padding-bottom"), 10) + parseInt(r.css("borderTopWidth"), 10) + parseInt(r.css("borderBottomWidth"), 10);\n\nif (c.outerHeight() &lt; r.outerHeight()) {\n    c.height(r.height () + rp - cp);\n} else {\n    r.height(c.height () + cp - rp);\n}\n</code></pre>\n\n<p>Hope it helps.</p>\n'}, {'answer_id': 1842279, 'author': 'cutcliffe', 'author_id': 224182, 'author_profile': 'https://Stackoverflow.com/users/224182', 'pm_score': 3, 'selected': True, 'text': '<p>Use jQuery for this problem; just call this function in your ready function:</p>\n\n<pre><code>function setHeight(){\n  var height = $(document).height(); //optionally, subtract some from the height\n  $("#leftDiv").css("height", height + "px");\n}\n</code></pre>\n'}, {'answer_id': 22628960, 'author': 'Chandrakant Manekar', 'author_id': 3454979, 'author_profile': 'https://Stackoverflow.com/users/3454979', 'pm_score': 0, 'selected': False, 'text': '<p>To grow the <strong><em>left menu div</em></strong> with same height as the right content div.</p>\n\n<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;\n\n\n&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;\n&lt;head&gt;\n&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;\n&lt;title&gt;Untitled Document&lt;/title&gt;\n&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;\n&lt;/script&gt;\n&lt;script&gt;\n    $(document).ready(function () {\n        var height = $(document).height(); //optionally, subtract some from the height\n        $("#menu").css("height", (height) + "px");\n        $("#content").css("height", (height) + "px");\n    });\n&lt;/script&gt;\n&lt;style type="text/css"&gt;\n    &lt;!--\n\n    html, body {\n        font-family: Arial;\n        font-size: 12px;\n    }\n\n\n    #header {\n        background-color: #F9C;\n        height: 200px;\n        width: 100%;\n        float: left;\n        position: relative;\n    }\n\n    #menu {\n        background-color: #6CF;\n        float: left;\n        min-height: 100%;\n        height: auto;\n        width: 10%;\n        position: relative;\n    }\n\n    #content {\n        background-color: #6f6;\n        float: right;\n        height: auto;\n        width: 90%;\n        position: relative;\n    }\n\n    #footer {\n        background-color: #996;\n        float: left;\n        height: 100px;\n        width: 100%;\n        position: relative;\n    }\n    --&gt;\n&lt;/style&gt;\n&lt;/head&gt;\n\n\n&lt;body&gt;\n&lt;div id="header"&gt;\n    i am a header\n&lt;/div&gt;\n&lt;div id="menu"&gt;\n    i am a menu\n&lt;/div&gt;\n&lt;div id="content"&gt;\n    I am an example of how to do layout with css rules and divs.\n    &lt;p&gt; I am an example of how to do layout with css rules and divs. &lt;/p&gt;\n    &lt;p&gt; I am an example of how to do layout with css rules and divs. &lt;/p&gt;\n    &lt;p&gt; I am an example of how to do layout with css rules and divs. &lt;/p&gt;\n    &lt;p&gt; I am an example of how to do layout with css rules and divs. &lt;/p&gt;\n    &lt;p&gt; I am an example of how to do layout with css rules and divs. &lt;/p&gt;\n    &lt;p&gt; I am an example of how to do layout with css rules and divs. &lt;/p&gt;\n    &lt;p&gt; I am an example of how to do layout with css rules and divs. &lt;/p&gt;\n\n&lt;/div&gt;\n&lt;div id="footer"&gt;\n    footer\n&lt;/div&gt;\n\n\n&lt;/body&gt;\n&lt;/html&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/35699', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3499/']