Bulleted Lists: Multi-Layered Fudge

by Nandini Doreswamy

81 Reader Comments

Back to the Article
  1. Josh, you posted while I was writing the above. You might want to read http://www.alistapart.com/articles/wayitssupposedtowork/ , which we published only a few weeks ago.

    In Nandini’s article, as in most ALA articles, an author is explaining his or her own solution to a problem. No one’s presenting it as definitive or sacred, and certainly not as infallible—and if we didn’t want collaboration and discussion, we’d close the forums.

    Copy & paste the code below to embed this comment.
  2. Holly bergevin and I did a piece on this idea some time ago:

    http://www.communitymx.com/content/article.cfm?cid=27F87

    ..but we did not originate the idea, we lifted it from Paul Novitski:

    http://novitskisoftware.com/test/multiplecolumnsEms.html

    ..and also Alex Robinsion:

    http://www.fu2k.org/alex/css/cssjunk/ListColumns.mhtml

    In fact another author independently wrote about it elsewhere, the same week we did.

    Personally, I like the idea, but the small height variances from col to col kinda ruin it for me. Oh well.

    Copy & paste the code below to embed this comment.
  3. Mr Malarkey did something similar, certainly worth a look.

    Copy & paste the code below to embed this comment.
  4. waitaminute—

    the author QUIT surgeory to become a systems engineer?!  (as if new zealand wasn’t small enough…)

    Copy & paste the code below to embed this comment.
  5. I’ve got a solution (untested) for making the list run vertically and split, without splitting the element:

    td {
    width: 50%;
    position: absolute;
    /* set margins, list styles, etc. */
    }
    td+td+td { /* two items in first column */
    margin-left: 50%;
    }

    Two main problems: the code needs to be modified for different sized lists, and it uses adjacent selectors, which IE doesn’t support (though I think IE7.js could fix that).  The second column also needs to be longer than the first to avoid the following paragraph from overlapping the absolutely positioned left half.  Though margins could be used to work around this problem.

    Copy & paste the code below to embed this comment.
  6. One very very easy way to ensure that you’re properly marking up your content semantically is to completely ignore presentation (layout, styles, etc.) until you’re finished writing the content. 

    Mark up the content properly, assign ids to each division, and you can style it with CSS later.

    This avoids problems with splitting a single list in two, adding presentational classes like “left” and “right” (What if you styled them to put the left class items on the right and vice versa?  How does the markup make sense then?), and enables you or someone else to alter the layout simply by changing the style sheet – for a redesign you should not need to touch the content code.

    There’s no need to break up the lists in two here.  If you’re already resigned to altering the content markup then what’s wrong with floating the list items and reordering the list manually (or via javascript)?  Isn’t that faster, easier, and cheaper (not to mention semantically more correct) than the proposed solution in this article?

    Copy & paste the code below to embed this comment.
  7. A request to all authors of articles to be published here is to make your articles much better exemplars to those out there learning from them:

    Don’t use px sizing!!!

    Please. No really, it’s bad.

    For poor schmucks like me who actually have a nice, high-res monitor, I can only see about 6 or 7 words across in the 597px defined as being the width of the ALA main column.

    Similarly, the examples in this article hard code the list items to 400px wide in a 800px wide box… with 15px padding.

    Surely, we’ve all learnt to use percentages and the occasional ‘em’ or ‘ex’ by now? This is about basic usability, not fancy formatting.

    Copy & paste the code below to embed this comment.
  8. First, I’m not frank.
    Second, many of the “what if the client wants it this way” or “that way” statements don’t apply to this article. Why? Because it appears the author’s client wanted <ul>s, not <ol>s. As a developer we have to use judgement and treat each design differently when we’re laying it out. This is one way of doing it, although I would have simply used • and discarded the use of the <ul> and its <li>‘s entirely- yet its nice to know that there is more than one way to utilize <ul>.
    Third, I love this site. Keep it up.

    Copy & paste the code below to embed this comment.
  9. I have one question which is not directly related to this article, but to the site you mentioned at the end of your article (and I’m asking because I suppose that you’ve designed it). The question is:

    On the top of this site you can see some links: “home”, “products”, … Next to each link there is a small icon. These icons are not part of the html, they are defined in the CSS and they are displayed as background images. This causes one serious problem: If you print the site, these icons do not appear!

    I wonder if there is a solution to this problem (of course I can tell my browser to print background images, but I want a way the designer can influence the printing behaviour with CSS).

    The same problem occurs to many style sheets shown in the CSS Zen Gaarden: Most style sheets replace some headlines with graphics. These graphics would never be printable because they are background graphics.

    If anyone has a solution to this problem, I’d love to read it in a new article for ALA.

    Copy & paste the code below to embed this comment.
  10. The solution for getting columns of list items really is simpler than all of you are making it out to be.  Moreover, you can do “in order” if you wanted.

    In fact, this is a fairly common request, so common that it lead to a faux-column example:
    http://cssirc.com/codes/?code=30#ordered-columns

    The solution is fairly simple: #ordered ol, #ordered li { margin: 0; padding: 0; display: block;
    } #ordered ol { position: relative;
    }
    /* creates the “first column” */ #ordered li { float: left; clear: left; width: 50%;
    }
    /* creates the “second column” */ #ordered li.col2 { /* basically UNDO everything set above */ float: none; clear: none; width: auto;
    }

    Copy & paste the code below to embed this comment.
  11. First, there’s no requirement of balance.  That is, you can have arbitrary numbers of “elements” in each column.

    Second, since this is for demonstration purposes only, and since IE doesn’t understand complex selectors, it uses simple class names to set off the alternate column.  It would probably be more helpful to distinguish them more descriptively.

    Lastly, IE screws up the numbering of ordered lists (1, 2, 3…) once you’ve removed a particular list item from the document flow (either by floating or absolute positioning). So you can’t rely on that.

    Copy & paste the code below to embed this comment.
  12. Suppose I want to create two ordered lists, side by side, about President Bush.

    The first list is titled “The Good” and contains 2 items. The second list is titled “The Bad” and contains 44 items.

    You are not going to be able to do this, in order, with your single list solutions.

    Just because Nandini used an UL instead of an OL does not mean that some people are not interested in the 2 list solution.

    I have been looking for a way to do this on my own web site for a while now. I had it working perfectly with absolute positioning…until my brother increased the font size on his computer and my text went flying out of the absolutely positioned div.

    Using relative positioning and flow trickery allows people to use larger text while viewing my site and it still looks like I intended it to.

    Thanks to Nandini and others who posted acceptable solutions to this issue. Thanks to those who posted solutions to the wrong issue (the “this is one list” issue). Some of those posts were very informative, as I use both OL’s and UL’s split into columns.

    Copy & paste the code below to embed this comment.
  13. Kody –
    Your example of “The Good” and “The Bad” might still be considered a single list with two different headings.  This is understood as “a list of Bush’s traits.”  The more I think about it, the more I disagree that they are two distinct lists.

    You can achieve a list with multiple headings fairly simply using a dl/dt/dd (which per the specs is not limited solely to definitions).

    Nevertheless, the problem described in the main article is definitely a single list problem.  As the example illustrates by saying things like “item 1” through “item 4”.  It would be different, perhaps, if the problem was “item 1.1” through “item 2.2”, for example.

    Finally, multiple list solutions are nothing new.  People have floated elements into “columns” for a very long time.  Float the first “column” and give a margin left to the second one.  There’s nothing special about lists, really. The only “issue” then is a containing floats problem which has very well documented solutions.

    Copy & paste the code below to embed this comment.
  14. Nandini, I looked at the linked site—it looks really good, but I thought you’d like to know that on the “about us” page, the text in the second paragraph goes past the center background box and spills out over the outer background. I’m using Safari 1.2.4 on OSX. Hope this helps!

    Copy & paste the code below to embed this comment.
  15. Thanks for your valuable feedback, Crystal. I’ll try my best to sort out the mystery of the paragraph spill.

    Copy & paste the code below to embed this comment.
  16. Did you know that Netscape 7.1 doesn´t render your page very well? The lists are missing!

    www.radiusnetworks.co.nz/computer-services.htm

    Copy & paste the code below to embed this comment.
  17. This solution is really great for a fixed number of bullets. What if your data is pulled in dynamically and you want the items to run in a columnar fashion? For example: a list of birthdays for a particular month that are ordered by day, top-to-bottom.  How could these lists get rendered semi-evenly across 3 columns (or so) using CSS?

    Copy & paste the code below to embed this comment.
  18. FWIW, I did a write-up on this about a year ago.  Please see:

    http://wickedways.org/articles/floatinglists/

    Copy & paste the code below to embed this comment.
  19. Not sure how this got published. 1. This would be cool if the it was all in one list with no special classes for left/right 2. Paragraph spacing issue should be fixed by just setting the default padding/margins for paragraphs. 3. More reasons…
    I expect more.

    Copy & paste the code below to embed this comment.
  20. i’ll be sure to use this in the future. this beats the implementation the make-shift solution i did for my portfolio site’s 2-column list.

    Copy & paste the code below to embed this comment.
  21. My apologies to the author, but this has got to be one of the least informative articles ever to grace the front of alistapart.  I know they’re hurting for content, but… geesh.

    anyhow, i took 5 minutes to take the authors approach and create a clean, completely unclassed page that accomplishes everything the author intended.  I eliminated floating the <ul>‘s left and right, and am floating them both to the left.  I assigned clear:both to the tags to prevent them from creeping upward at all.  I used PIE’s float-clearing trick to make sure my div wrapped the entire setup.

    It’s as close to 100% semantic as we can get with CSS2.

    http://www.reaxion.org/listapart.html

    Copy & paste the code below to embed this comment.