By default, most browsers display the ordered list numbers same font style as the body text. Here is a quick CSS tutorial on how you can use the ordered list (ol
) and paragraph (p
) element to design a stylish numbered list.
Basically, what we need to do is style the ol
element to Georgia font, and then reset the p
element (nested in ol
) to Arial.
Make an ordered list. Don’t forget to wrap your text with a <p>
tag.
<ol>
<li>
<p>This is line one</p>
</li>
<li>
<p>Here is line two</p>
</li>
<li>
<p>And last line</p>
</li>
</ol>
Here is how the default ordered list will display:
Style the ol
element:
ol {
font: italic 1em Georgia, Times, serif;
color: #999999;
}
The list will become like this:
Now style the ol p
element:
ol p {
font: normal .8em Arial, Helvetica, sans-serif;
color: #000000;
}
Your final list should look like this:
View my demo file to see more samples.
Arctic
Thanks! It is useful.
Biscuitrat
Huh, that makes things so much easier. I knew you could stick a good deal into a list-item, but I forgot that you could style them independently also. Thanks! And lovely site! This one’s a keeper :)
Wolf
Agree completely with Biscuitrat
Mohammed
Sir, very useful indeed, i liked to use the ’em’ unit insted of the pixel/point, but not so sure how do you measure font size using the ’em’ ?
one more thing, would u write a tutorial about the new DIV/CSS trend, using DIVs instead of Tables ?
And what do you recommend to read about CSS ?
Thanks Alot.
God blesses
Justin
Wouldn’t it be easier to just style the <li> tags instead of adding <p> tags inside the list items? Just a though… haven’t tried this, though, great idea!
Luis
Justin, i tested it here (ff), and unfortunately if you use
ol li {
font: normal .8em Arial, Helvetica, sans-serif;
color: #000000;
}
it will overwrite the “ol” style.
Justin
Ah, dang! Well, ’twas worth a shot, eh?
Jermayn Parker
aaahhhhh very good indeed.
Some people will argue about the p being in there but it makes sense to style the actual listing and not font.
@Mohammed – CSS reading I would recommend notepad. If you are after div styling tuts it should not be too hard to do so because it is now the ‘common’ way of coding for websites.
yakuter
Thanks for this great post. However there should be more about ul, ul li ul.classname, ul li a:hover etc ;)
@Mohammed here you should find a chart that shows the ration of px,em and points. My way is to make em equal to pixel in body section of css
body {
font-size:%75;
}
Then 1px=1em ;)
Aleksey
Problem with transparent the close button ( X )
MarkB
Wikkid… only thing with this is that it’d be extra work to get the p tag into the li tag when working with a CMS – especially if the site will ultimately be controlled by a client who probably couldn’t be bothered.
I’d suggest just bolding the li and then instead of
ol p
style it with
ol bold
That will make it a bit more ‘CMS friendly’ :)
Heri
MarkB, an excellent point, but sadly that just proves what I’ve said for years. A CMS should be for content database management, hence Content Management System. A CMS should have nothing to do with how the content is displayed. How content is displayed should be handled by a separate CDS, or Content Display System (a term I kinda made up myself).
I’ve written my own universal CMS that I use for most of my clients, and I write a separate CDS for each client’s website. It’s a quick and speedy process to code a CDS when you’re already familiar with the database structure of the CMS. This way content is truly separated from the design. I don’t feel hindered in the least as to how I design and code my websites, because I never have to put up with the templating garbage that you have to deal with on most content management systems. It also works better for my clients; since my CMS has a client and webmaster mode, my clients don’t get overwhelmed by a bloated WYSIWYG editor and the bloated settings and modules that most systems today, have.
But not everyone is familiar with server-side programming (PHP, ASP, SQL, etc.), hence they couldn’t code their own CDS even if they wanted to; so I guess I’m probably a little over-opinionated in this matter. So don’t take what I just said too seriously.
Mohammed
Thanks Guys for your replies.
Yes, liked the CSS although i used to use tables and still can do things fixed and nice with Tables, but with CSS still hard to align-middle, center objects, wrap columns !, i know there are alot of workaround and hacks, but still not 100% portable i guess. but am trying.
@Heri ? are you a designer or programmer?, for your CDS, how do you split the formatting out of the CMS db ? or it is just a way of displaying the layout ? providing options of different templates or ready customized profiles of displaying the contents.
it is still a nice idea indeed.
Good luck.
God Blesses.
Jenny
Oh I’ve been looking for something like this. Thanks.
Jason
This is a fun tip. Thanks. I’ll be using this soon.
Lewis
Great tutorial, Thanks!
المصمم توقيع
Nice tip :)
but it is not semantically correct; if anyone cares.
fontaine
I don’t know you can read chinese or not .( My English is poor) Your site is so beautiful and the article is also nice for me ! (hope my word no mistakes)
Diego
I’d like to know if it’s possible to display 1) instead of 1. in ordered lists. Thanks.
Eirik
I’m a bit curious about your CDS, a term I have never heard before. I do like the idea though, and like MarkB points out, a p within a li is not what I expect any other than someone working with web would get. It is hard enough to make systems that makes publishing easy for customers.
A way to go would perhaps be to render a
*list thing
* and another
as a li with a p inn it when it is outputted to the screen (well, actually: swap the star with li p before insert to the db) . But: if you have some CDS that makes it possible to keep markup out of the database, that would be great. I’m not asking you to shear your code, but how to go about starting a project like that would be nice.
I searched your page for CDS, and a lite google search, but nothing that strikes me as the answer.
Web Design Blog
I’ve come across a better way (although not well supported)…but it does require less markup.
li:first-child { color: green; }
li { color: blue; }
this is *supposed* to color just the numbers green.
Anonymous
This is a tip? I fail to see what is so profound about this tip. Its just simple CSS that anybody can do. So you can italicize the numbers and change the font to something else for the text. What was so worthy about writing this as an article?
Anastasia
@Anonymous: I actually found this tip quite useful. I wouldn’t have known how to do this otherwise, and I’ve been wantingto learn how to give list numbers and text different styles ever since I saw the cool effects on Jon Hick’s website.
I like this website by the way, it’s very useful, although I’m not a big fan of the layout. Especially the font! *kills arial*.
Gab
Why not use ‘span’ to style the list items differently? This would be a bit more semantically correct, would it not?
Carly
This is great, but I’d love a tutorial on fun ways to style ul lists, like horizontal navigation. I’ve been looking online for days for different ways…!
Alexandra
Very simple and useful tip. I always wanted to style my numbers but never knew how. This is a great approach!
Milan
Hi thanks a lot for this small and fine tutorial!!
Madhavan M
HI Buddy! Thanks a lot for your useful tips. It’s very easy and simple to understand. Good job, thanks again.
Fabian
I tried to add this on my wordpress blog but wordpress removes the tag.
So I tried to apply the “normal” style onto the element but that doesn’t work.
Any ideas??
Joomlabased
Good turorial. Thank you
sunrise
very useful and simple tip!
Foseptik Temizleme
very useful tips thanks
kane
This is quite good thought :)
computer jobs
Thanks. very useful information, all the time i was look for it ;)
vincent
good idea, thx
my name
hi alert(“hey look, injection attack in your face”);
Jakub Chodorowicz
Thanks for the tip, I already used in one of my websites (its useful to use some Javascript to add the extra markup, I used ‘span’ instead of ‘p’)
Jayme
When I click the “View my demo” link, a popup appears with ol p styling examples. Is the popup java? If not, how was it programed? Can this technique be done with CS3 behaviors?
Steven
Very useful tutorial thanks.
CSS 2.0
Great tutorials on this site!
CSS 2.0 is very powerful to customize your html elements.
Blog Sites
Nice article for designers, I will use this trick in my next blog site.
Robin
Nice tip…so simple yet looks great!
scott
Hello Looking for some code to make a customise can i have the type being (a) (b) (v) etc! like <ol type=”(a)” etc) oor
Web design company
Thank you for the great solution. The current design trends are for clean cust minimalist websites In such css driven designs, styling ordered lists and bullet lists presents an excellent opportunity to go that extra mile.Its interesting to see what simple formatting using css can achieve!
dfs design www
nice and easy
Annanimous :-P
Good one actually :)
Annanimous :-P
This is a nice article.. Great !
Annanimous :-P
http://www.pixobel.com
Pieter
Thank you for this one!
I used it on my site.
-visible multimedia
ntas
Nice !
Met-art
Nice article for designers
sanat
thanks
Michael Wilson
Stupid easy – and such a brilliantly beautiful way of presenting lists.
Ray Acosta
Dear Nick:
Thanks, thanks, thanks. Only a designer could explain “programming jargon” so clear like your posts. I love your site and the spirit on it. By the way, to be a designer you have a great understanding of programming!
Greetings,
Ray
andy
Anyway to make the text wrap under the number using the ol?
Peter
Do you know how to get rid of the period after the number in ordered lists? I want to style the numbers with the number only, and a circle around it, probably by putting a circular image in the background of the li.
Xtence
Very nice, i like typography, didnt think ’bout this one, thanks !
rightie
Beautiful. But is there any way to control the line height of the paragraphs in the p section to achieve a uniform look within the whole list?
Scott Foley
Amazingly simple yet beautiful results. Nice one.
flashfs
Very good tutorial for beginners. Thanks.
Quyen
This means I have to manually put the text between the tags every time I make an ordered list. In wordpress 2.8 however, the tags are removed after a switch between Visual and HTML type mode. Then all my work is gone.
Is there any function or php loop I can use to stop this? Or better yet, insert tags automatically.
zhuzhiyan
i use the old html first ,now i use css/html ,very useful
Ed
Thanks for the inspiration!
Bill
Anyway to make the text wrap under the number using the ol?
bagsin
nice skill. strong css
Cyrus
Great , Style Your Ordered List
Great article. CSS saved web design
Cyrus
Visit http://www.psdtoxhtmlcoder.com
prabhu
Very Nice.. very Simple… Thanks….
Mike
Simple and easy for beginner like me.
Webchester
Very nice lesson :) Thanks.
yennaiv
tnx. :) love it!
yennaiv
i like ur BG too.
vincent
The designs showed here show what simple and tasteful design is all about. Another one to consider
Bob Marley
Or just use a span instead of a p. Its more semantic and it works in Firefox…
Shelt
Bob, what planet are you on? how is a span more semantic than a P lol
Luke Stanley
Shelt, Bob is right, because P is a paragraph. Span doesn’t imply that it’s a paragraph.
Laura
Love IT!
Devin Walker
Very useful trick there! Similar to using spans for the same purpose of styling
khay
thank you so much for sharing. nice post. i like it :p
youtube
so with this i can also make it colored or different size but to change the single line color ill do the same but with each right ?
replica sunglasses
The designs showed here show what simple and tasteful design is all about
tütüne son
The designs showed here show what simple and tasteful design is all about. Another one to consider
Henry Peise
I just heard the gossip that since there’s some technic problems on white iphone 4, iphone 4b is going to release. It that true?
Juno Mindoes
Want to buy the hotest white iphone 4 Conversion Kit? http://www.whiteiphone4.com will be your best online store. Don’t hesitate to buy the charming iphone 4 Conversion Kit!
supratall
I just heard the gossip that since there’s some technic problems on white iphone 4, iphone 4b is going to release. It that true?
Uçak Bileti
takimi almasak ne olurdu
Uçak Bileti
tanrim kaderimi baştan yaz
Colin Oakes
Thanks for the tip. Just came in really handy.
altın çilek
That’s Great! Thanks for the post!
hcg damla
The designs showed here show what simple and tasteful design is all about
Bay Area Webdesigner
Thank you for this quick tutorial. Very helpful in a pinch!
kilo aldirici
ignore weight
How To Put On A Condom | How To Get Taller
It works perfectly!!!:) Thanks.
http://www.howtogettallersecrets.com
I am really happy I discovered your website. This is quite an interesting read.
dexx
Excessive fear, anger, and work under stress last pregnancy, infants can lead to excessive hassaslığa. Intense emotions, going through the mother’s blood circulatory system and brain functions that affect the baby in some leads to the release of chemical
Fernando Jorge
Hey there… I love these examples, this tutorial is excellent.
I have a question that I haven’t seen anywhere yet (maybe I haven’t searched enough). Does anyone knows how to make an ordered list like:
Point 1 – something
Point 2 – another something
Point 3 – yet another
What I meant was to have something written before the number (in this example “Point “).
Is this possible to be made?
Many thanks to all! :)
Valery
hey Fernando,
Yes, it’s possible.
Please try it :
ol li:before{
content:’Point ‘;
position:absolute;
left:-20px;
}
bye
Malaysia Online Radio
This is pretty cool although it’s simple !
shaggy
@Fernando
Use
shaggy
@Fernando
Use Definition List
http://www.w3.org/MarkUp/html3/deflists.html
New-york-Suboxone-Physicians
Another interesting post. Thank you for the information, It is good to see such quality posts. I am subscribing to your blog. Keep them coming.
complex 41
hello thank you for this great post 23
δονητές
Thank you for another magnificent article. Where else could anyone get that type of information in such an ideal way of writing? I’ve a presentation next week, and I’m on the look for such information.
How to Save My Marriage from Divorce
Really it was very helpful information!
How to Save My Marriage from Divorce
Really it was very helpful information! I was looking for this for a long.
digitalpbk
Awesome .. now i can have some fancy numbers..
Edward Sotelo (@EdwardSotelo)
Hmm, I wish you could style the list style. Or can you?
.
.
Webdesign Links
Cool, exactly what i was looking for!
Eyewebmaster
Very informative post. Most of the simple task to do sometimes need your help.
Thank you!
Alex
I wonder if there’s a way of doing this without the extra ‘p’ markup. Or if you can somehow just traget the number in the ol as a seperate item to the rest of the list.
Thomas | Website Design Durban
Simple, yet very effective.
Bags Men
Great web site! I genuinely love how it truly is simple on my eyes and the data are nicely written. I am wondering how I may well be notified whenever a new post has been made. I’ve subscribed to your RSS which should do the trick! Have a terrific day!
Veeps
I’ve wound up using your styling expertise a number of times and decided to finally say thanks. THANKS!
allsaints
You really make it appear so easy along with your presentation but I to find this topic to be actually one thing that I believe I’d by no means understand. It sort of feels too complex and very vast for me. I am having a look ahead for your next publish, I will attempt to get the cling of it!
ram
Iam using this list styles on my website – is there a way to design the list numbers with images?
Sam
Not my code but hope it helps you RAM.
ul {
list-style-type: none;
padding: 0px;
margin: 0px;}
li {
background-image: url(sqpurple.gif);
background-repeat: no-repeat;
background-position: 0px 5px;
padding-left: 14px; }
You can also use an image to style the list with:
ul
{
list-style-image: url(‘sqpurple.gif’);
}
but it’s not cross browser compatible.
Jean
YOU ARE A GOD!!!! This is the only place I found info on this that actually worked. Even the wordpress codex was useless. THANK YOU!!!!!
Online Survey Software
Thanks for the free tips!
Web designer
Really nice!Thanks!
magazin
You really make it appear so easy along with your presentation but I to find this topic to be actually one thing that I believe I’d by no means understand. It sort of feels too complex and very vast for me. I am having a look ahead for your next publish, I will attempt to get the cling of it!
resimler
definitely, a BIG BIG deals.thx, for article
cctv
nice article
gifeasy
Very good thanks!!
Ibiza
I genuinely love how it truly is simple on my eyes and the data are nicely written. I am wondering how I may well be notified whenever a new post has been made. I’ve subscribed to your RSS which should do the trick! Have a terrific day!
lakshmi
good idea! thanks.
Adrian
Here is a great deal I came to know in terms of discount for SoGoSurvey Yearly Enterprise Account. Goto the home page of SoGoSurvey after you’ve login to your Free Account. Click on Upgrade and select the Enterprise Package. If on the payment page you enter SOGOEN in the Promo Code section and you will see that they offer you a $499 deal instead of $590. I purchased one. Try the code, maybe you get lucky too.
Viron Media
This is a great idea. So simple yet very effective.
oto cam
Very good thanks!!
maket pasta
thank you good job!!!
sineklik
thank you good post..