Bulleted Lists: Multi-Layered Fudge

Designing our company’s website in CSS was coming along nicely until I hit a roadblock. The challenge was to create two columns of bulleted lists in the flow of the text. The layout I had in mind was something like this:

Article Continues Below

Paragraph 1
Bulleted list | Bulleted list
Paragraph 2
Bulleted list | Bulleted list
Paragraph 3
Bulleted list | Bulleted list
…and so on

I tossed around some lists that worked fine in IE 6, but caused a headache in almost every other browser. Perhaps I could have smashed through the roadblock using horizontal lists. But I’ve always found it easier to float, so that’s what I did.

Floating ULs#section2

To solve the problem with floats, let’s assign two classes of unordered lists, ul.left and ul.right, which we’ll place in a div named “div” that’s 800 px wide (yes, 800 is just an arbitrary number; you can set it to whatever width you want). The basic CSS reads:

  #div {width: 800px;}
  ul.left {float: left;}
  ul.right {float: right;}

For the markup, we’ll use three paragraphs of Lorem Ipsum text, slot in the unordered lists, and place the whole lot in the div. The markup looks like this:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.

  • Item 1: Left
  • Item 2: Left
  • Item 3 Right: A long item
  • Item 4 Right: This is longer, just for fun

Duis aute irure dolor in reprehenderit in voluptatevelit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.

  • Item 1 Left: Varying length
  • Item 2 Left: This one varies in length, too
  • Item 3 Right: This is shorter
  • Item 4 Right: Right

Pellentesque et erat. Quisque at quam. Donec accumsan tellus at tellus. Donec metus. Sed sit amet ante vitae metus imperdiet varius. Vestibulum pulvinar bibendum.

  • Item 1 Left
  • Item 2 Left
  • Item 3 Right: Another long item
  • Item 4 Right: Right

The trouble with Dilbert#section3

The trouble with our UL floats is this: the text of the paragraph below creeps up between the two floating ULs. Also, the UL floating right loses alignment.

To overcome this, we’ll do three things:

  1. Set the margin, padding and border to zero. This is for consistency, to prevent browsers from meddling with the alignment of our bullets with different “default” padding / margins.
  2. Specify the bullets. Again, this is to maintain consistency across browsers. We’ll use simple square bullets.
  3. Declare the width of the ULs: Here, we’ll assign an arbitrary width of 400 px for each UL, half the width of the containing div.

The CSS now looks like this:

  #div {width: 800px;}
  
  ul.left {
    float: left;
    width: 400px; 
    margin: 0px;
    padding: 0px;
    border: 0px none; 
    list-style-position: inside;
    list-style-type: square;
  }
  
  ul.right {
    float: right;
    width: 400px; 
    margin: 0px;
    padding: 0px;
    border: 0px none; 
    list-style-position: inside;
    list-style-type: square;
  }

The spacing gremlin#section4

IE 6 leaves an equal amount of space before and after the ULs. However, later versions of Mozilla (1.7.3), Opera (7.54) and Firefox (1.0) leave space before the ULs, but none after. To ensure that the space before and after the ULs is equal, we’ll assign a padding of 15px to the top and bottom of the ULs, like so:

  #div {width: 800px;}
  
  ul.left {
    float: left;
    width: 400px; 
    margin: 0px;
    padding: 15px 0px;
    border: 0px none; 
    list-style-position: inside;
    list-style-type: square;
  }
  
  ul.right {
    float: right;
    width: 400px; 
    margin: 0px;
    padding: 15px 0px;
    border: 0px none; 
    list-style-position: inside;
    list-style-type: square;
  }

IE 6 is happy. There’s some space left after the ULs in Mozilla, Opera and Firefox, but the space before and after the ULs is still not exactly equal. This uneven spacing is a result of the default space left after the preceding paragraph, so it’s the paragraph that needs defining to correct this. Defining the margin or padding at the top of our ULs will not solve this problem. 

We want to cook our fudge to perfection, so we’ll add a paragraph class and called .no-space and set its margin and padding to 0:

  .no-space {
    margin: 0px;
    padding: 0px;
  }

We’ll also change the markup to include this paragraph class:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.

  • Item 1: Left
  • Item 2: Left
  • Item 3 Right: A long item
  • Item 4 Right: This is longer, just for fun

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat.

  • Item 1 Left: Varying length
  • Item 2 Left: This one varies in length, too
  • Item 3 Right: This is shorter
  • Item 4 Right: Right

Pellentesque et erat. Quisque at quam. Donec accumsan tellus at tellus. Donec metus. Sed sit amet ante vitae metus imperdiet varius.

  • Item 1 Left
  • Item 2 Left
  • Item 3 Right: Another long item
  • Item 4 Right: Right

Now it seems everyone’s happy, more or less. We’re almost done.

It would look better, though, if the left column of bullets was indented, rather than being stuck to the left margin. To achieve this end, we’ll do the following:

  1. Declare relative positioning for the left UL.
  2. Specify its distance from the left. In our example, let’s make this distance 50 px.

The CSS now reads:

  #div {width: 800px;}
  
  ul.left {
    float: left;
    width: 400px; 
    margin: 0px;
    padding: 15px 0px;
    border: 0px none; 
    list-style-position: inside;
    list-style-type: square;
    position: relative;
    left: 50px;
  }
  
  ul.right {
    float: right;
    width: 400px; 
    margin: 0px;
    padding: 15px 0px;
    border: 0px none; 
    list-style-position: inside;
    list-style-type: square;
  }
  
  .no-space {
    margin: 0px;
    padding: 0px;
  }

Things are looking good. That’s it from me, really. Oh, and you can view the page that gave me the two-list headache in the first place. The technique used there is quite similar.

I hope you enjoy the multi-layered fudge. Add your own yummy gif bullets and serve piping hot!

About the Author

Nandini Doreswamy

Formerly a surgeon, Nandini Doreswamy is now a systems and wireless LAN engineer living in Auckland, New Zealand. Her passion for web standards emerged when she designed websites for the two companies she owns and operates, Radius Networks and Helion Training.

81 Reader Comments

  1. Thanks for that, Rikkert. I read your article on classes with interest and gleaned some information about semantics from the W3C page you’ve linked it to.

    Just one suggestion – you may want to validate the CSS on your site (default.css at http://www.rikkertkopes.com) and the HTML markup for your article at http://www.rikkertkoppes.com/thoughts/class-and-style , as there are several errors coming up in both, in W3C’s validator.

    Thanks again.

  2. [offtopic:] The fun at of reading ALA is vanishing rapidly if the first four pages of comments contain nothing but slashing authots, complaining about ALA article standards etc.

    If you like to play the part of the two old men at the balcony in The Muppet Show, shouting ‘boo’ at every act, that’s fine. The problem is that you are not half as funny and you make the audience leave the theatre in the end. Please, open up your own theatre if you are so shocked by the low quality of ALA[/offtopic]

    I’m interested in the javascript versus two UL-list solutions:
    – javascript:
    When CSS is turned off you still have a split list, which I guess is fine since it will flow with the text. But what if the screen is really small and a CSS float would force the ul’s the be stacked upon each other, which is the behaviour you want, what will happen to the split list?.
    When javascript is turned off, the result would be one long list, which is not what you intend, but would still be readable and workable within the layout.
    – CSS: When CSS is turned off the ul’s would be stacked up vertically in the right order. I guess this is requested behaviour and would leave the flow of text intact.

    Are there any other considerations? And what would the unobstrusive javascript solution look like?

    @arnoud berendsen: your example shows one list in Firefox 1.0, not a split list.

  3. My complaint about the semantics of your solution would be that you use two lists while it is actually one.
    The point of semantics is that the document itself represents the structure of the data and should not contain anything that implies something visual. In other words it should group data but not specify what it should look like. So it should not say wether text should be big or bold, or in our case tell if the list should be displayed in two columns. If you would look at the document without CSS there would be two lists while it essentially is one.

    If I say that the document can’t specify wether text should be big or not, I mean that in a entirely presentional way. It should specify that the text is a header for example, which would in most browser display in a bigger font. Same goes for italics or bold, if you emphasize text it will be displayed in italics in most browsers, strong emphasis is often displayed as bold text.

    The problem with your classnames is that you specify ‘left’ and ‘right’, which basicly controls the visual aspect instead of structural.

    @ Martijn:

    I don’t agree that arguing over the quality of the articles is useless or offensive.
    This article needs improvement and that should be said. We all learn from this discussion and excellent alternatives have been proposed.
    What does bother me is the continuous repeating of “let’s do it with a floated li with a width of 50%”

    So to get back on the main issue here, I’ve done this in the past by floating li’s with a width of 50% – oi I’m contradicting myself in the above paragraph.
    For unordered lists this is in my opinion the best solution since order is not important. After a quick thought I believe for ordererd lists a unobtrusive Javascript would do the trick because we preserve semantics. if I have time I will test this and post the results and a script.
    I do have to reconsider if it’s a good idea to split ordered lists anyway.

    To conclude I would like to thank the author for posting this since a useful discussion has been initiated. As a sidenote I think ALA should’ve used their new icon to emphasize on the non-pure semantics.

  4. I posted a similar article to this on my site asking how to arrange a split list. My problem was using two horizontal table cells and one list split between them. You may be interested to read the various solutions readers came up with in the comments:

    http://www.designdetector.com/archives/04/02/AQuestionOfHTMLPart2-SplitLists.php

    Regarding the article here, I would initially have considered a table. Since the list isn’t a numbered one, the order is irrelevant. So just put each list in a separate cell. This will also work when CSS is turned off.Otherwise the layout is broken, using the solutions posted here, as the list becomes a single column without CSS.

    I would not consider using JavaScript here, as the user may well have it turned off. (Again the layout will be broken and a single list will appear.)

  5. I don’t want to sound offending or arrogant, but I think you got it all wrong; the layout *should* be broken without CSS because HTML isn’t supposed to show layout in the first place.

    Using tables is even worse, like said before these list-items are not tabular data. It’s just a list of items, where a table is not. Consider the unstyled document, it should display a list (who cares if it’s split up in two rows, it’s still a list) and not a table, where the user would except some sort of relation between the items (a table should always have a header explaining the meaning of the data, which we do not need here).

  6. is: users (also applications – like a search engine) with CSS turned off usually say: “give me the data and not the design”, so be nice to them and give them what they ask, don’t go and split up lists in two if it’s actually one.

  7. @Arikawa:

    Another way to reset the default stylesheets is to define a default for all elements. W3C has a basic version of this for HTML 4 at http://www.w3.org/TR/CSS21/sample.html
    It may be a bit weighty, and there are some you’ll have to fix to be cross-browser compliant (abbr, acronym, br and remove the BDO section) but it gives you the most control.

  8. The design by Nandini seems to be fine to me. Just because there are multiple ways of designing doesn’t make one wrong or right as long as it conforms to web standards.
    The page was designed as an unordered list for 4 items- not numbered. Seems many posters are more interested in posting their “grand way of designing”.
    The amount of harsh attention this article has received is unnecessary.

    Can you do it differently? Sure, but isn’t that the beauty of design?

    Does it work in multiple browsers? YES.

    Does it meet what the client’s needs? YES.

    Does it slow the page load down to a point where users will leave? NO.

    You all are getting lost in the dot-and-tittle over a few bytes- you’ve wasted more space and energy than is necessary (I am speaking to the negative posters, not the ones who have kindly offered other possible solutions). To the positive posters: thank you for your continuing development of the CSS/Web standards community.

    To the negative space-wasters: Stop posting just to hear yourself talk. Learn what you can from the article and move on.

    Thank you Nandini for posting an interesting solution approach to this design. Good luck with your endevours and keep posting.

    ALA: keep posting these articles because I can learn something new from everyone.

  9. First off, I suppose I should take a position on the best solution so far; mine is: http://www.unbf.ca/altiustu/upload/multilayer/ If you are going to split a single list in 2 and label one “left” and one “right,” the lesser evil is certainly to preserve a single list and label individual LIs as “left” or “right”, no?

    But the larger question, in the larger context of ALA, is the way a solution is presented. I think that we can see from teh responses thus far that to be presented a solution such as teh article proposes as somehow DEFINITIVE or as a BEST PRACTICE defintiely puts the reader’s teeth on edge, preparing each to respond aggressively to faults. I mean, the article’s technique is no “Sliding Doors,” as I am sure most will ackowledge.

    I, for one, would be much more interested in articles such as these being presented as a conversation starter, encouraging the ALA community to propose their own solutions (as many have done here). If the author were to ackowledge at the beginning that s/he recognizes the drawbacks to splitting a list between ULs and requiring presentational class names, and that this solution proposed here is nothing more than one attempt at a solution, I think the community would respond more positively, and with no fewer great proposals of their own.

  10. Friends,

    Disagreement about techniques and passionate discussion about alternatives are healthy and productive. Hyperbole and personal attacks are not. The perpetrators of the latter seem inclined to hit-and-run tactics, and probably won’t read this. So instead of spending a lot of time on them, I want to thank you, our regular readers and contributors, for helping keep the forums professional, civil, and focused.

    You’re the reason our authors spend unpaid hours developing and writing and testing for ALA articles, and why it’s worth it for our also-unpaid staff to keep making the magazine go.

    Based on the number of proposed alternatives to Nandini’s technique we’ve seen posted so far, it’s clear that there isn’t a consensus on the One True Way to solve this design problem. Happily, the article and forum will provide a great resource for people who need it.

    Finally, one word to the less-helpful participants. The inevitable comments about ALA’s decline don’t make much of an impact on the magazine’s staff, but they do tend to derail the conversation and take focus from the article / techniques under discussion. If you feel strongly about it, please contact the crew directly or take it to your own site. If you’re just letting off steam in public for kicks, you’re wasting everyone’s time.

  11. 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.

  12. 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.

  13. waitaminute–

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

  14. 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.

  15. 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?

  16. 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.

  17. 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

      s, not

        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

          and its

        • ‘s entirely- yet its nice to know that there is more than one way to utilize
            .
            Third, I love this site. Keep it up.
  18. 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.

  19. 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;
    }
    
  20. 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.

  21. 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.

  22. 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.

  23. 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!

  24. 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?

  25. 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.

  26. 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

      ‘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

Got something to say?

We have turned off comments, but you can see what folks had to say before we did so.

More from ALA

I am a creative.

A List Apart founder and web design OG Zeldman ponders the moments of inspiration, the hours of plodding, and the ultimate mystery at the heart of a creative career.
Career