Introducing the CSS3 Multi-Column Module

by Cédric Savarese

53 Reader Comments

Back to the Article
  1. Marek, good catch. Thanks for the correction.

    Paul, the tools and information available in javascript to deal with line length and word separation are rather limited. This makes the column breaking logic a real headache. Basicaly, the scripts removes words after words until the column reach the desired height. The comma should be considered part of the word, but as you noticed the markup in between breaks the logic here… It’s probably something that can be dealt with in the script though.

    Copy & paste the code below to embed this comment.
  2. Hey Cedric,

    Nice work and thanks for the examples.  I have one questions since I’m already using Dean Edwards latest IE7 scripts to enhance the native css support in IE.  Would you be able to recommend an approach to providing your css3 enhancements as an additional module that could be loaded along with his css3 module?  It looks like you base your functionality in part on his cssquery which IE7 also does.  Seems like it should be possible to separate out the css3 enhancements so cssquery is common and this would be an extension to the IE7 project.  That would be really handy.  Any ideas would be appreciated.  Again nice work.

    Mike

    Copy & paste the code below to embed this comment.
  3. I noticed that the script does the DOM wizardry by creating extra DIVs given random six letter combinations (like “ufsvmb”). I suppose making them a bit more meaningful would be helpful (besides, what about the unlikely event of a collision, eh?)

    Personally, I think that columns will open up the way to more paged forms of web presentation: splitting content up into several pages (something that personally irks me). The thing about doing that is that it makes things a bit easier when you want to bookmark, but I prefer my scrolling to your page turning any day.

    Copy & paste the code below to embed this comment.
  4. i find the multi column idea very good. i would really appreciate it if someone could post some templates or example easy to integrate. Perhaps i can include them on my “css”:http://www.mycelly.com site …

    Copy & paste the code below to embed this comment.
  5. Thanks for the article Cédric, I’m finding it very useful in a current project. But I’ve run into a problem where your script seems to clash with at least one other script I’m using. I have a script in place that allows me to unobtrusively send external links to new windows. This script stops working with the multi-column script in place. If I rearrange the order, placing the external.js script last, the multi-column script stops working. I’m not script-informed (graphic designer with almost no coding abilities, sorry) so if there’s a way around the problem I’d be happy to here about it. (Otherwise I’ll have to skip one of the scripts, with a sigh and a tear, possibly.)

    Copy & paste the code below to embed this comment.
  6. I want to try out a horizontal blog using this… I think it would probably be a nice break from normal vertical pages.

    Copy & paste the code below to embed this comment.
  7. Hey, just wrote an article about how Flash designers and CSS Purists are similar here:

    http://www.flash99good.com/?p=85

    thought folks here might be interest?? duno?
    cheers,

    Copy & paste the code below to embed this comment.
  8. Fred, send me a link to your page, I’ll check it out (c.savarese at 4213miles.com).
    Regarding the randomly generated id, they’re intended for internal use only, but it’s true that if you want to apply some css to one of the column only, a predictable id would be better.
    Mike, I use Dean Edwards’s CSSQuery, but I’m not familiar with the way IE7 works… we can talk about it further if you want. Email me.

    Thanks

    Copy & paste the code below to embed this comment.
  9. The message title says it all!

    Copy & paste the code below to embed this comment.
  10. I am a cross-over from print design (magazines & junk-mail) – so hearing about this just gave me shivers! Imagine!!!!! A page that reads like a magazine—REALLY!

    One thing that does concern me is the scrolling. I have made sites that keep the scrolling to a minimum, and am going to be experimenting with CSS to see if I can do the same.

    Oh… THANK YOU for the Suckerfish Dropdown! Doing Velocity templates with drop menus was a real challenge until I found your tutorial! Now I have more time to experiment rather than debug!

    Aloha nui!
    LZ.designer

    Copy & paste the code below to embed this comment.
  11. I would really, really like both a column-height property, and not least a column-max-height property, last one making it possible to set the max-height of the columns (surprise!). If the content then overflows the columns, there should be created ‘more columns’ vertically.
    That would actually be useful for something, quite contrary to what you achieve in Firefox 1.5 (RC1), when setting the height property on the ‘column-element’, giving you more columns horizontally (which is an understandable behaviour though, as it’s height, not column-height).

    Copy & paste the code below to embed this comment.
  12. I just thought it was ironic how the following line was placed into the article, yet the line after it had 14 words:

    Between 8 and 12 words seems to be the

    On, a more serious note, great insight, but will we really be able to use CSS3 for some time?

     

    Copy & paste the code below to embed this comment.
  13. I think this is a great way to make large amounts of text more readable (subject to the columns not being longer than the length of the viewport, of course). I’m definitely considering using it on a new website I’m just starting work on.

    One quirk I’ve noticed though is that the text in the first column has some whitespace above it, whereas the others do not which throws off the alignment of the text lines. This is readily visible in Test Case 5.

    Any way of sorting this out?

    Copy & paste the code below to embed this comment.
  14. My first column ends in the middle of bullet number 4 and is continued in the second column; it is renumbered as bullet 3.  And again, the second column ends in the middle of bullet number 6, yet is reassigned bullet number 3 in the third column.

    Quite unexpected, indeed.

    Copy & paste the code below to embed this comment.
  15. I publish my blog through blogger. I added the articall class to my linked css stylesheet. I then added the script below the link to my stylesheet. Then added a <div class=“article”> div around my post. Still no worky. www.ksauce.com Let me know if you know why. kurt.potts@gmail.com

    Copy & paste the code below to embed this comment.
  16. I remember wishing that CSS could do something just like this.  I think if the major browsers will impelement this in a reliable fashion, then it will increase the rate at which designers drop their nested tables in favor of semantic markup.

    Copy & paste the code below to embed this comment.
  17. It is my opinion that until all browsers support CSS3 web development will have to stick to calculating split points via scripts, either server side (e.g php) or client side (e.g. javascript solutions as shown).

    With the article script and indeed with the CSS3, what is really required is the abilty to set any element as no_break_within.

    Using the javascript supplied you can fool the javascript with
    ‘<span><ul class=“adlist”><li><img >text</li></ul></span>’
    to keep the text together. Unfortunately the side effect is that the last column tends to be the longest (at a guess the split point is set to the beginning of one of the elements).

    What is really required is if classname=“nobreak” or somesuch the split point becomes the end of the element.

    Another niggle which is required to be truly successful is orphan and widow controls although I fully realise the complexity this could cause.

    Thanks again for a useful article.

    Copy & paste the code below to embed this comment.
  18. http://www.buero-newyork.com

    Copy & paste the code below to embed this comment.
  19. First, 8 to 12 words per line is NOT the “ideal” or even magical number. It actually depends on a few variables – the entire length of the column, the point size of the type, etc. There is a technical and mathematical way of determining proper word count on a line…but I digress.

    My point here is that this feature is potentially very valuable. It must be used in moderation though. Usability concerns arrise as well. One major difference between print and web, is that a web browser scrolls. BUT I have hopes for this and hope it will become more of a standard in the future. Even if a bunch of junk comes from it, it merely helps sort out good design from bad… though I should be careful with a wish like that, people start to forget good design :( Anyway, nice article and let’s keep our fingers crossed.

    Copy & paste the code below to embed this comment.
  20. I have an unordered list I needed to dynamically break into 2 columns. This solution works almost beautifully. While it does split the unordered list into two columns it breaks the href tag on the first entry of the 2nd column leaving that particular item unlinked.

    Copy & paste the code below to embed this comment.
  21. Fixed the issue. Line 26 contains the variable “splitableTags” – I removed ‘A’ from the list of HTML tags and all functions as it should now.

    Copy & paste the code below to embed this comment.
  22. I’ve implemented the basic CSS3 multi-column functionality in a “template for the Serendipity blog engine (Serendipity themes)”:http://themes.daves.me.uk. It’s imaginatively called ‘Multi-column’ and of course it only works currently in Firefox. I could implement a javascript solution for other browsers until they deign to support multiple columns. As all the content is generated dynamically, I’ve only used column-gap and column-count but it seems to work well

    Copy & paste the code below to embed this comment.
  23. In the example test case 6 on this site you can see that the list item which goes to the top of the next column, does not work as a hyperlink.
    I am trying to use the script to do a very similar thing, and it does not work on my site either.
    I hope you can fix this, since I would like to use the script very much.

    Best regards,

    Linda

    Copy & paste the code below to embed this comment.