Placed in: Home arrow Programming arrow CSS arrow 8 different ways to beautifully style your lists
8 different ways to beautifully style your lists

The use of HTML lists (<ol> for an ordered list, <ul> for an unordered list) is very common these days. Today, we're going to look a little bit further than creating regular lists, by showing 8 different ways to beautifully style your HTML lists with CSS. We'll use some pure CSS techniques to make a bored list look awesome (and even have some extra functionality).

As a reminder, here's how a default ordered list and a unordered list look like:

  1. Ordered list item #1
  2. Ordered list item #2
  3. Ordered list item #3
  • Unordered list item #1
  • Unordered list item #2
  • Unordered list item #3

And check out the demo to see what we're going to create with it.

Demo beautifully style your lists   Download beautifully style your lists

Looks much better, doesn't it? And you get all that, just by adding a couple of sweet CSS stuff. Want to know how? Here we go!

List #1 : Simple navigation

The most common use currently for using a list on your web page, is because for navigation. In this HTML/CSS example, the code is shown that creates a simple, minimalistic yet beautiful navigation structure.

HTML

 
<div id="list1">
   <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">Blog</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Contact</a></li>
   </ul>
</div>

CSS

 
/* LIST #1 */
#list1 { }
#list1 ul { list-style:none; text-align:center; border-top:1px solid #eee; border-bottom:1px solid #eee; padding:10px 0; }
#list1 ul li { display:inline; text-transform:uppercase; padding:0 10px; letter-spacing:10px; }
#list1 ul li a { text-decoration:none; color:#eee; }
#list1 ul li a:hover { text-decoration:underline; }

List #2 : Different font for numbering

The problem with lists, is that you can't make the looks of the list be different than from the text. The number of the list always must have the same color and font as the text.

But, by adding an extra element in the list-item, you can work around these limitations and create a very slick list. Here's how to do it:

HTML

 
<div id="list2">
   <ol>
      <li><p><em>The Netherlands</em> is a country in ...</p></li>
      <li><p><em>The United States of America</em> is a federal constitutional ...</p></li>
      <li><p><em>The Philippines</em> officially known as the Republic ...</p></li>
      <li><p><em>The United Kingdom</em> of Great Britain and ...</p></li>
   </ol>
</div>

CSS

 
/* LIST #2 */
#list2 { width:320px; }
#list2 ol { font-style:italic; font-family:Georgia, Times, serif; font-size:24px; color:#bfe1f1;  }
#list2 ol li { }
#list2 ol li p { padding:8px; font-style:normal; font-family:Arial; font-size:13px; color:#eee; border-left: 1px solid #999; }
#list2 ol li p em { display:block; }

List #3 : Image bullets

You can change the bullet style of an unorered list to some other build-in values, but you can also change them into an image. This technique can make your list even prettier. Let's see how this is done.

HTML

 
<div id="list3">
   <ul>
      <li>Java</li>
      <li>.NET</li>
      <li>C++</li>
      <li>PHP</li>
   </ul>
</div>

CSS

 
/* LIST #3 */
#list3 { }
#list3 ul { list-style-image: url("../images/arrow.png"); color:#eee; font-size:18px; }
#list3 ul li { line-height:30px; }

List #4 : iPhone Style List

This list is taken from the the iPhone Contacts App with CSS and jQuery. It shows the Contacts.app style list as you can see them on the iPhone. Just a little bit more eye candy for your web site.

HTML

 
<div id="list4">
   <ul>
      <li><a href="#"><strong>Toronto</strong>2004</a></li>
      <li><a href="#"><strong>Beijing</strong>2008</a></li>
      <li><a href="#"><strong>London</strong>2012</a></li>
      <li><a href="#"><strong>Rio de Janeiro</strong>2016</a></li>
   </ul>
</div>

CSS

 
/* LIST #4 */
#list4 { width:320px; font-family:Georgia, Times, serif; font-size:15px; }
#list4 ul { list-style: none; }
#list4 ul li { }
#list4 ul li a { display:block; text-decoration:none; color:#000000; background-color:#FFFFFF; line-height:30px;
  border-bottom-style:solid; border-bottom-width:1px; border-bottom-color:#CCCCCC; padding-left:10px; cursor:pointer; }
#list4 ul li a:hover { color:#FFFFFF; background-image:url(../images/hover.png); background-repeat:repeat-x; }
#list4 ul li a strong { margin-right:10px; }

List #5 : Nested lists

Nested lists (lists inside lists) can be extremely useful and beautiful to style. By combining the third technique (Image bullets), we can create a "expanded list". Of course, with the help of jQuery, you can make this expanding even work (but we'll stick to CSS techniques only).

HTML

 
<div id="list5">
   <ol>
      <li>Google
         <ol>
            <li>Picasa</li>
            <li>Feedburner</li>
            <li>Youtube</li>
         </ol>
      </li>
      <li>Microsoft
         <ol>
            <li>Corel Corporation</li>
            <li>Zignals</li>
            <li>ByteTaxi</li>
         </ol>
      </li>
      <li>Yahoo!
         <ol>
            <li>Xoopit</li>
            <li>BuzzTracker</li>
            <li>MyBlogLog</li>
         </ol>
      </li>
   </ol>
</div>

CSS

 
/* LIST #5 */
#list5 { color:#eee; }
#list5 ol { font-size:18px; }
#list5 ol li { }
#list5 ol li ol { list-style-image: url("../images/nested.png"); padding:5px 0 5px 18px; font-size:15px; }
#list5 ol li ol li { color:#bfe1f1; height:15px; margin-left:10px; }

List #6 : Roman numbering + inline multiline

By default, an ordered list uses numbers (1, 2, 3, 4 etc.) as list style type. By changing this value in CSS, you can create other numbering systems, for example the roman numbering style.

Also by default, a list displays it's bullets outside of the elements (you can see this pretty good in example #2 - different font for numbering). To get around this, we'll need to change the list-style-position to make the numbering display inside.

HTML

 
<div id="list6">
   <ol>
      <li>Lorem ipsum dolor sit amet, ...<br />Fusce sit amet ...</li>
      <li>Aenean placerat lectus tristique...<br />Vivamus interdum ...</li>
      <li>Mauris eget sapien arcu, vitae...<br />Phasellus neque risus...</li>
      <li>Phasellus feugiat lacus ...<br />Duis rhoncus ...</li>
   </ol>
</div>

CSS

 
/* LIST #6 */
#list6 { font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Lucida, Geneva, Helvetica, Arial, sans-serif; }
#list6 ol { list-style-type: upper-roman; color:#eee; font-size:14px; list-style-position: inside; }
#list6 ol li { }

List #7 : Comma separated inline list

Lists are mostly used to display a number of items under each other, in a totally new element. But what if you wanted an inline list? You can achieve this, by setting the display property to inline. But when you're in text, you can prefer to make it a comma seperated list. How to achieve this? With the :after pseudo code.

HTML

 
<div id="list7">
   <ul>
      <li>First inline item</li>
      <li>Second inline item</li>
      <li>Third inline item</li>
      <li class="last">Fourth inline item</li>
   </ul>
</div>

CSS

 
/* LIST #7 */
#list7 { }
#list7 ul { color:#eee; font-size:18px; font-family:Georgia, Times, serif; }
#list7 ul li { display: inline; }
#list7 ul li:after { content: ", "; }
#list7 ul li.last:after { content: ". "; }

List #8 : Rotated navigation

Here's a last small technique that works with CSS3 (Supported by the latest versions of Firefox, Safari and Chrome). When hovering a block element, you'll get a rotated hover state. Might not be that useful, but it can be beautiful to see.

HTML

 
<div id="list8">
   <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">Blog</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Contact</a></li>
   </ul>
</div>

CSS

 
/* LIST #8 */
#list8 {  }
#list8 ul { list-style:none; }
#list8 ul li { font-family:Georgia,serif,Times; font-size:18px; }
#list8 ul li a { display:block; width:300px; height:28px; background-color:#333; border-left:5px solid #222; border-right:5px solid #222; padding-left:10px;
  text-decoration:none; color:#bfe1f1; }
#list8 ul li a:hover {  -moz-transform:rotate(-5deg); -moz-box-shadow:10px 10px 20px #000000;
  -webkit-transform:rotate(-5deg); -webkit-box-shadow:10px 10px 20px #000000;
  transform:rotate(-5deg); box-shadow:10px 10px 20px #000000; }

Conclusion and Download

There you see, you can create extraordinary things with an ordinary list. And all this with the power of CSS.

Demo beautifully style your lists   Download beautifully style your lists

I hoped you liked the use of these lists. Did you learn anything new today? And do you use any form of list that isn't placed in this article (breadcrumbs maybe)? Feel free to share.


Tags:  lists html css webdesign

Interested in this topic? You might enjoy another article I've written called

Did you like this article? Subscribe to my feed or email to keep updated on new articles.

Spread the word and submit to:
Digg!Reddit!Del.icio.us!Facebook!StumbleUpon!
Comments
Add NewSearchRSS
Janko   2009-10-19 19:53:03
Gravatar image Nice examples and very well explained.
Sergio Gandrus - #8 is amazing   2009-10-19 21:28:10
Gravatar image Very good tutorial.
The 8th list is really outstanding
Vivekanand - Well Done   2009-10-20 08:57:16
Gravatar image Awesome list styles..... thanks for your effort on the same...
Marco - Thanks a lot!   2009-10-20 09:18:32
Gravatar image Thanks a lot Janko, Sergio and Vivekanand - glad you enjoyed these examples. Hope you learned something new and your comments keep me motivated writing more and more of this :D !
Harsh - Nice Thanks a lot   2009-10-20 13:57:13
Gravatar image I like this post, Thanks a lot for this wonder full information....
Kurt Waegeman - jee, a rotated hover state...   2009-10-20 20:29:11
Gravatar image That's the first time I see a working example (list # 8 that is) of a rotated hover state.
I guess it's about time to start digging into CSS3 a bit more.

Nice article dude
Marco - Thanks !   2009-10-21 07:32:58
Gravatar image Thanks Kurt - Glad you liked the example! There are more CSS3 related articles on Marcofolio, you also might like the Creating a polaroid photo viewer with CSS3 and jQuery :) .
Edward Rayne - Awesome!   2009-10-20 22:08:07
Gravatar image Nice list, really liked #2 and I'm going to have to play with #8 some. That's a pretty awesome effect that I wasn't even aware of. Thanks.

Bill Ludwig | Edward Rayne Web Development
jukswebguy - You are really good   2009-10-21 08:11:07
Gravatar image I like #5
Xaby Web Design - You are brilliant!   2009-10-23 18:10:46
Gravatar image hoot! i like #2 and thanks for the effort!
znebula - Sir Fink   2009-10-25 08:18:36
Gravatar image What's the problem with up/down arrows in Chrome?
vibol - re: Sir Fink   2012-08-31 13:31:39
Gravatar image please show me about the template code of css
Anonymous - CSS   2009-10-28 15:10:25
Gravatar image I learned the new CSS abilities. Only thing that sucks is the css will make you fail W3C CSS Validator.
Stan   2010-01-15 21:50:51
Gravatar image Nice tutorial (and congrats with being mentioned on Smashing Magazine)
Tristan Davis - Good stuff   2010-01-16 19:44:33
Gravatar image there is some great stuff here.

I used number 8 in my wordpress blogroll / links page here: http://www.tristandavis.co.uk

Thanks a lot!
Robine - Great!   2010-03-10 09:05:31
Gravatar image Very nice, I have used it on my website, thanks a bunch :lol:
Feem - Wie is de man   2010-03-18 20:47:05
Gravatar image Marco kan maar 1 ding zeggen over jouw <img src=hock:' /> en dat is dat je in mijn ogen rock like a ......... <img src=illy:' />
Je bent echt een inspiratie voor de jeugd
w3cvalidation - W3C Validation | Whats Is W3C Validation | W3C Val   2010-04-12 12:44:16
Gravatar image Nice information, I really appreciate the way you presented.Thanks for sharing..
Neelabh Katte   2010-08-10 18:17:08
Gravatar image Very useful
Thanks alot
Ovidiu - Great iPhone style uls   2010-09-01 16:10:52
Gravatar image The iPhone list style is great! I will use it on one of my websites. Thanks!
paul   2010-09-23 19:57:06
Gravatar image The list 5 is great, but where is the pic- images/nested.png
george - You rock Marco   2011-01-31 15:09:41
Gravatar image You rock marco these stylesheets are amazing .I plan to use it on my website. Thank you for sharing your knowledge with the world
linda   2011-04-12 16:23:22
Gravatar image ;) wowow nice cooollll I love you
e11world - Web Design & Development   2011-04-13 17:57:29
Gravatar image This is one of the most useful posts on the net! Thank you so much for this!
Fernando Jorge - Very, very nice indeed!!!   2011-04-15 20:54:52
Gravatar image Hi there Marco.

First of all, congratulations... this is one of the best CSS tutorial I've seen concerning Lists.


I have, however, a question on OL lists.

Those subtitles:
List #1 : Simple navigation
List #2 : Different font for numbering
List #3 : Image bullets
(...)
List #7 : Comma separated inline list
List #8 : Rotated navigation

Are they possible to be made with OL and CSS?


Thanks for any help you may give me! :cheer:
prasad - psdk   2011-05-24 12:50:19
Gravatar image Thanks buddy... it was amazing
hirmani80 - WebHostingPad Review   2011-08-02 09:05:51
Gravatar image I had really like it very much for helpful info in this blog and useful info in this blog. I had really like it very much for providing the nice info in this blog that to great posts are visible in this blog.lot of topics are interesting in this blog. I am really very great for the info wise and nice info in this website. Thanks a lot for sharing the nice info in this blog
Aravind - coll style lists   2011-09-28 11:48:43
Gravatar image Thank you very much dude for the beautiful lists styles....i used the last one its good n working fine
jay - thx   2011-12-11 18:51:39
Gravatar image kick ass styles. great typography. you sir rock!
Yusuf Tokgoz - Property in TUrkey says thank your   2012-02-12 13:56:05
Gravatar image thank you very much, the most complete tutorial about ul and li so far on the net
Juti - thank you for sharing!   2012-02-29 20:06:21
Gravatar image :) I love it. thanks!
user - thanks   2012-05-04 18:17:37
Gravatar image number 8 is awsome, thank's for the article :)
user - thanks   2012-05-04 18:18:36
Gravatar image :cheer: number 8 is aswome , thanks for the article
faddy - Thanks   2012-05-26 04:58:07
Gravatar image Thanks
Hassen - very good   2012-08-24 12:03:35
Gravatar image Thanks for this great post ! :woohoo:
valarmathi - thank you very much   2012-09-06 07:40:36
Gravatar image really nice codes that help to my website development...
Jess   2012-10-07 23:49:11
Gravatar image Loving this!
Kusadasi   2012-10-27 13:23:10
Gravatar image Iphone style is good i like it thank you
Kusadasi - Kusadasi   2012-10-27 13:24:07
Gravatar image :lol: Iphone Still is good i like it
stevenkirika - love it   2012-11-27 05:47:12
Gravatar image loved List #8 : Rotated navigation. thanx much :)
Marder - Very nice.   2012-12-28 15:03:46
Gravatar image Thanks. My Favorite is List #2.
Marder - Very nice.   2012-12-28 15:04:18
Gravatar image My favorite is List #2. Thanks!
Jon - Quick Question   2013-01-16 16:06:10
Gravatar image I'm using something similar to the iPhone style list on my page, but I have a question:

How do I make it so the link stays highlighted once the user clicks the link and the page loads??? After the page loads, the menu goes back to its default state. I have many pages and don't want to add "a.aSelected" to each page.

Thanks, Jon
Bilal - great   2013-03-12 22:45:30
Gravatar image these are best lists Thanks
Dark Lord   2013-03-13 09:53:55
Gravatar image Actually 2004 was at Athens Greece :)
murtaza   2013-03-25 10:55:32
Gravatar image The image list is awesome , I will use that thanks
murtaza   2013-03-25 10:56:45
Gravatar image The image list is awesome , I will use that thanks
mrigi   2013-03-31 03:40:10
Gravatar image The front of the logo is awesome. You can use new thing.
ddsd - ddd   2013-04-24 09:43:21
Gravatar image dd
ita - cool   2013-05-12 17:40:45
Gravatar image nice list.. thank you very much
love this..
Read more...
Name:
Email:
  Gravatar enabled.
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Security Image
Please input the anti-spam code that you can read in the image.
Unsubscribe from e-mail notifications.
 
< Prev   Next >
Subscribe

Subscribe to Marcofolio