Web Standards
  Home arrow Web Standards arrow Matching div heights with CSS and JavaScri...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WEB STANDARDS

Matching div heights with CSS and JavaScript
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 34
    2005-03-14

    Table of Contents:
  • Matching div heights with CSS and JavaScript
  • The kingdom of non-matching heights
  • More non-matching heights just around the corner
  • The JavaScript solution

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Matching div heights with CSS and JavaScript


    (Page 1 of 4 )

    It's not unusual for the layout of a Web page to feature multiple columns. Unfortunately, when creating this layout while using general <div> containers, you can end up with columns of uneven height, depending on their content. This looks very unprofessional. Alejandro Gervasio explains a way to keep your column heights even using CSS and JavaScript.

    Introduction

    CSS based design is really a powerful approach for most Web developers who consciously keep a website's contents separated from their visual presentation, which improves the site's overall maintenance and flexibility. Without a doubt, these virtues have provided designers with new possibilities for styling and positioning elements within Web documents very easily.

    While tables still remain, for good compatibility reasons, the most used technique to define the layout of Web pages, <div> elements have gained considerable territory because they efficiently perform the same task. However, div-based layout exposes some undesirable artifacts when it is applied. Certainly, one of the most common pitfalls encountered when building up a two or more column liquid layout is the inability to give each general <div> containers the same height. It is desirable to achieve a consistent look, but also difficult, because of the dynamic nature of contents to be included in general <div> containers.  Due to this issue, many websites present layout columns with uneven heights, which looks very inconsistent to the eyes of visitors.

    However, we can do much more to solve this problem. Over the course of this article, I'll show you a simple but powerful approach to match heights for general layout divs, thus eliminating that ugly effect that makes some sites appear quite unprofessional. Using CSS and JavaScript, we'll find a nice solution without feeling a sense of doom. So, it's time to move on and tame those wild divs!

    More Web Standards Articles
    More By Alejandro Gervasio


       ·  I think that the exposed technique is easy to understand and effective to maintain...
       · The idea of javascript is good, but it's just working with IE only. I didn't play...
       ·  Hello friend, The solution works in IE, Netscape 6+ and Mozilla. So, It might...
       · I have only been able to get the script working in IE 6. Been having a mess about...
       · I don't understand why a web developer would do this. If a web surfer has...
       · Hello again,The script works fine in Firefox and Netscape 6+. I've tried it, and...
       · Yes, what you're pointing is correct. It's another possibility to achieve the same...
       · Modern browsers, like FireFox 1.0+ (and I'm guessing Netscape 6+) support CSS2.1,...
       ·  Well, I think that display: table-cell could be pretty easily to be implementedon...
       · Am I the only one that thinks it is crazy that we are running around coming up with...
       · Your opinion it truly worthy, since the use of tables is currently strong. The...
       · Actually it doesn't work in firefox. To get it working, you need to add 'px' to the...
       · The addition of the 'px' unit is recommendable. However, I've tested the script in...
       · I've tried this over and over and over again on my three column absolutely...
       · The script works great in IE, Firefox and Opera. However, I had a problem with the...
       · Thank you for your feedback here. In fact, the problem you mention shouldn't be that...
       · I was struggling with this - I could get it to work in html but not xhtml, and then...
       · I meant "http-equiv" meta tag - apologies.
       · Hello,Thank you for your introducing your comments on my article. Also, I'm glad...
       · No problem at all, friend. I understood what you meant.Thank you.
       · The script does exactly what it is supposed to do (thanks by the way for the...
       · Thank you for your detailed feedkack on my article, and particularly about your...
       · This seems unnecessarily complicated. This effect (as mentioned before) can be...
       · Hello Martin,Thank you for commenting in this article. Although the script is...
       · Alejandro, any way to have this great JS code working also on HXTML? Please let me...
       · First off, thank you for commenting here. Now, concerning your question, if you're...
       · I've looked at about 50 tutes for a pure CSS solution to this problem as I agree...
       · First of all, thank you for commenting here. Now, concerning the DIVS issue, if...
       · IS THAT FRIGGIN COOL OR WHAT? MAN I FRIGGIN LOVE JQUERY!
       · Thank you for commenting on my article. Since it was written a few years ago, this...
       · Hi,No you're not the only one but I think we are in the minority.I have read...
       · Thanks for commenting on my article. Yes, all the time it’s up to you to decide to...
       · Cool... Even though the author himself states this may be an outdated solution, it...
       · Thanks for the comments on my article and for your great post. I really appreciate...
     

    WEB STANDARDS ARTICLES

    - Completing a Configuration for Chrome and a ...
    - Getting Connected with Firefox and Chrome
    - Configuring Servers and Databases with Chrome
    - Configuring Firefox for Chrome and a Server
    - Designing the Elements of a Web Page
    - Matching div heights with CSS and JavaScript
    - Forms
    - Get Down With Markup
    - If I Said You Had a Beautiful Body...
    - Web Standards in Dreamweaver Part 3
    - Web Standards in Dreamweaver, Part 2
    - Web Forms
    - Making Lists Using XHTML
    - Web Standards in Dreamweaver, Part 1







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT