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

1. HTML source code
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:

2. ol element
Style the ol element:
ol {
font: italic 1em Georgia, Times, serif;
color: #999999;
}
The list will become like this:

3. ol p element
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.
Thanks! It is useful.
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 :)
Agree completely with Biscuitrat
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
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!
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.
Ah, dang! Well, ’twas worth a shot, eh?
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.
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 ;)
Problem with transparent the close button ( X )
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’ :)
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.
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.
Oh I’ve been looking for something like this. Thanks.
This is a fun tip. Thanks. I’ll be using this soon.
Great tutorial, Thanks!
Nice tip :)
but it is not semantically correct; if anyone cares.
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)
I’d like to know if it’s possible to display 1) instead of 1. in ordered lists. Thanks.
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.