Two Column Lists Using HTML

Posted by on October 1, 2009 with 58 Comments

I know there are a million methods of breaking a list into two columns, but many of them involve additions to the CSS or new tables to be created.  But I like a different way.  The markup is all html, and it can easily be used in WordPress posts (using the view HTML tag at the top of the post editor).  The markup is pretty simple.  It is basically just two divs, one floated left and one floated right, with each only getting a percentage of the container.  Below is the markup in real time.

<div style="float: left; width: 50%;">
<ul>
<li>Left Item 1</li>
<li>Left Item 2</li>
<li>Left Item 3</li>
<li>Left Item 4</li>
<li>Left Item 5</li>
</ul>
</div>
<div style="float: right; width: 50%;">
<ul>
<li>Right Item 1</li>
<li>Right Item 2</li>
<li>Right Item 3</li>
<li>Right Item 4</li>
<li>Right Item 5</li>
</ul>
</div>

Live on the site it will look like:

  • Left Item 1
  • Left Item 2
  • Left Item 3
  • Left Item 4
  • Left Item 5
  • Right Item 1
  • Right Item 2
  • Right Item 3
  • Right Item 4
  • Right Item 5
This simple little bit of code can be used to make as many columns as you want.  I like the freedom to make things as ugly as I want. All columns except the last (furthest right) need to be floated left.  And don’t forget to change your percentages accordingly.

UPDATE:

Below is the actual code for doing three columns.  This is at the request of Bradford Ulrich.

<div style="float: left; width: 33%;">
<ul>
<li>Left Item 1</li>
<li>Left Item 2</li>
<li>Left Item 3</li>
<li>Left Item 4</li>
<li>Left Item 5</li>
</ul>
</div>
<div style="float: left; width: 33%;">
<ul>
<li>Middle Item 1</li>
<li>Middle Item 2</li>
<li>Middle Item 3</li>
<li>Middle Item 4</li>
<li>Middle Item 5</li>
</ul>
</div>
<div style="float: right; width: 33%;">
<ul>
<li>Right Item 1</li>
<li>Right Item 2</li>
<li>Right Item 3</li>
<li>Right Item 4</li>
<li>Right Item 5</li>
</ul>
</div>

Notice that only the last column is floated right.  Only the furthest right div needs to be floated right. All others should be left, in order you want them to appear.  The percentages also change to allow each to have the appropriate amount of room.  If you had four, guess what the percentages would be. RIGHT! 25%.   Here is what that code looks like again.
  • Left Item 1
  • Left Item 2
  • Left Item 3
  • Left Item 4
  • Left Item 5
  • Middle Item 1
  • Middle Item 2
  • Middle Item 3
  • Middle Item 4
  • Middle Item 5
  • Right Item 1
  • Right Item 2
  • Right Item 3
  • Right Item 4
  • Right Item 5

-matt

Be Sociable, Share!
Filed Under: WordPress

Get Updates via Email:


Don't miss a single post. Enter your email below to receive my latest blog post via email.


And... Follow me on Twitter.

Comments

  1. I love you. I’ll be using this soon. How do you do more than 2 columns? Can you post an example of that? I’m code dumb.

  2. Matt says:

    There you go Brad. Clean and simple. Let me know when you use it so I can see it in action. We used this exact code on the “Who’s Here” page on CatalystCouch.com.

  3. Jill Anderson says:

    Thank you Matt. This is exactly what I was searching for this morning — although I haven’t got it to work yet. I copied in your code and replace Left Item #/Right Item # with my data and yet I still have only one list. I am using WordPress and am in the HTML tab of a new post. Hmmm….will keep trying.

  4. Matt says:

    Jill, I meant to make a note for everyone about this. A friend of mine was using the code and we discovered that if you just copy and paste the code, it will not work. I am pretty sure the problem lies in the quotes. When copied, they are not correct. Go back to your code and just remove the quotes and add new ones. That little fix should help.
    -matt

  5. Jill Anderson says:

    It’s perfect!! Thank you so much, Matt.

  6. Anne says:

    This may seem creepy, but I think I love you. This is exactly what I needed to know!

  7. archie says:

    This is great.
    Exactly what I wanted to do on my posts.

  8. Thank you! So much simpler than many alternatives.

  9. mars says:

    I have been searching for days to make colums, good script thanks, and easy to apply !

  10. Lahesha says:

    I am so EXCITED that you posted this! However, I’m trying to make columns on a wordpress page using your instructions, with the added complication of images along with the text for each bulleted item.

    Is it possible? I’m playing with the alignment/code to try to get the images to line up, but it’s not working.

    Any tips?

    • Matt says:

      Lahesha -

      Glad you find this useful. If you would like, you can email me ( matt [at] mattdanner [dot] net ) with the url of your problem and I can try to take a look at it for you.

      -matt

  11. Geoffrey says:

    Thank you so much Matt. This is what i have been looking for and so thankful. Am working on my website now and it has really helped me. Thank Once again.

  12. Asad says:

    Neat and simple.
    Great work.

  13. Jorge Alonso says:

    Hola Matt:

    Muchas gracias por tu información. Me fue muy útil.

    Saludos desde Argentina

    Jorge

  14. Thank you so much. This is just what I was looking for.

  15. Ash Starkey says:

    Awesome. I’ve tried lots of suggestions and plug-ins that work but they stop other plug-ins working on the same page.
    This is a simple fix and works a treat.
    Thanks and respect,
    Ash

  16. Katy says:

    Hi, thanks for this code! I am wondering if there’s anyway to remove the dots next to each item? Thanks!

  17. vERNON says:

    Hi Matt I used your code an is it possible to add hover and a color change to it.
    Thank You
    VRY

    • Matt says:

      VRY –

      You can add any additional CSS that you would like. You can either add it by using inline style ex: <div style="my style goes here"> or by adding classes to the div and adding the css in your stylesheet.

      -matt

  18. R says:

    Nice Very good Thank you

  19. Thanks for this idea! I was laboriously using tables. You can actually float the middle one right or left, or float them all right or all left.

  20. Eve006.75 says:

    Finally, found simple straight forward html code for 2 columns for use on Ebay listing – thanks a mill

  21. Megan says:

    thank you thank you thank you this is amazing!!! got rid of the bullet points though :)

  22. Mike says:

    Thanks a lot for this tip. I just put into action and worked great :)

  23. Shanna says:

    I am trying to use this for my tumblr to get more than one column on my tumblr and it is not seeming to work, help!

  24. Matt says:

    DUDE, i don’t know why but this was so hard for me to find a simple solution to. A million thanks to you!

  25. JGini says:

    Yes! You rock! Thanks for this easy and very useful code.

  26. Alice says:

    This is fab!! Is there a way to remove the bullet points? they look messy on my links tab :(

  27. Jacqui says:

    I used this code for some button links in a widget sidebar. Thank you soooo much for this. I had spent all day trying to figure out how to get it to work. Works great. Since I used graphic buttons with a link in my columns, there is a little too much spaces between the “rows.” Is there a way to shrink that down and have my buttons closer together (from top to bottom)?

  28. Rudy says:

    I tried your coding with the div’s on my table of content. It works perfect in Chrome, but in Firefox and Explorer, the RH column appears under the LH column to the RH side. I coded both div’s with valign=”top”to no avail.

    Plse advice

  29. amal says:

    nice , tutorial exactly what i was looking for
    thanks Matt

  30. Claire says:

    So helpful – thanks!

  31. Jack says:

    how do you loose the bullet points? in other words, how can I make the bullet points disappear?

    thanks!

  32. Jason says:

    I used your code for 3 columns, but the data does not divide evenly into 3, and because of that the text underneath the columns is running up into the columns. Is there anything special I have to do if the the data in the columns is not going to be even? thanks!

  33. Jazmin says:

    Thank you so much for this! I’m new to HTML and this helped a lot.

  34. Cody says:

    This is great! The only problem I am having is that when I put the code in there seems to be a large gap between my title and the lists and I cannot seem to find out how to fix it in the code…

  35. Bronwen says:

    Hi – thankyou!
    If I wanted to number the 2 columns to go from 1-10 how would I do that? Currently, when I click on number bullets in the wysiwyg they go from 1-5 in each column.
    Thanks for your help.

  36. Anavoom says:

    okay im totally dumb for html, so im stucked -.- how do I put pictures in? so I have like pictures, not item1, item 2 etc etc ? :S

  37. This is perfect. I’m having a problem with the next paragraph after the 3 column list. It is wanting to be up and right aligned with the bottom of the right, third column. Its not bulleting but it is starting there as if it were the next in the list. What can I do to help get it moved down to its own spot?

    Here is the post I’m having trouble with.

    Thank you!

    Mandy

  38. Cassidy says:

    Hey Matt,

    First off, thank you so much for posting this – it’s such a huge help. I’ve used the two column code in WordPress, but unfortunately when I input text below the columns, it keeps wrapping around the column on the left. I’ve tried overriding this by inserting between the divs, but then that throws the right column out of alignment. Do you happen to know of any other way that I can override the word wrapping? I’m a bit of an HTML novice so forgive me if I’m overlooking something obvious here. Thanks for your help!

  39. Cassidy says:

    Sorry, I meant to say by inserting br clear=”left” between the divs.

  40. Ron Cuenca says:

    thank you so much :D it was a big help

  41. Daniel says:

    Finally someone that speaks human language. Thanks a lot!

  42. Jabeen says:

    Hi Matt,

    Thanks for showing the simple way to make two columns by html. But what to do if I want the two columns to be centered with a specified gap?

  43. Stephen says:

    Appreciate the reference!

  44. VizFact says:

    Thanks! Bad ass tip!, got me away from those evil table codes.

  45. mira says:

    how can i remove the bullets?

  46. Sean says:

    Thanks very much for the code! Works great!!

  47. Kyla says:

    Hi Matt,

    Is there a way to put more space between the two columns so that they aren’t so cramped? Or maybe a bar/divider?

    Thanks.

  48. Jamika says:

    u saved my life thanks some much….

  49. Harmik says:

    Hi Matt,
    Thank you for you sweet code. I was wounder if I could add dots or dashes in space between items

  50. John Gusty says:

    It must be nice to know that 4 years later… this post is still helping people. SAVED MY MORNING! Thanks Matt. You’re awesome.

Leave a Reply