Cascading Style Sheets (CSS); Formatting Lists
This article will show you
how you can change the style of individual lists, all lists on your page,
and all lists on your entire web site by changing just a few things on your
By changing one word in your global style sheet, for example, you can change
all your web site's ordered lists style type from lower-case roman numeral
to upper-case alphabet.
If you're unfamiliar with CSS, please read the "Cascading Style Sheets (CSS);
Getting Started" and "...Learning More" articles, both linked from the archives
index page at
Some CSS styles render differently according to the browser. When you use
CSS, test your pages with the major browsers to become familiar with what
most of your users will see.
To work with this article, use a web page like this:
The breaks within the list item lines demonstrate how line wraps will appear,
without having to use long lines to see the effect.
Notice the two style properties for the ordered list tag OL. Later, we'll
introduce a third, one to use an image as item bullets.
The example could also be a UL tag; both OL and UL can be styled the same
The first property is "list-style-type". The example specifies "decimal,"
but other values are available. Here is a list:
Causes the list to be numbered with decimal
numbers; 1., 2., 3., etc. This is most browser's
default for ordered lists.
Causes the list to be numbered with lower-case
roman numerals; i., ii., iii., etc.
Causes the list to be numbered with upper-case
roman numerals; I., II., III., etc.
Causes the list to be labeled with lower-case
alphabet characters; a., b., c., etc.
Causes the list to be labeled with upper-case
alphabet characters; A., B., C., etc.
~~ disc (not "disk")
Causes the list to be bulleted with a disc
character, a filled circle. This is most browser's
default for unordered lists in the first level.
Causes the list to be bulleted with a circle
character, an outlined circle.
Causes the list to be bulleted with a square
character, whether outlined or filled depends
on the browser. This is most browser's default for
unordered lists in second and subsequent levels.
Causes the list to have no label or bullet. The
effect is like a left paragraph indent.
Some of the above can be specified
without the use of CSS, as an attribute in the UL or OL tag. The UL tag can
have a style="disc" attribute, for example, and the OL tag can have a style="i"
attribute for lower-case roman numerals.
The advantage of using CSS is that all lists on a page or on an entire web
site can be changed by changing only one style sheet. And, with CSS, an ordered
list can be made to use bullets and an unordered list can be made to sport
The second property in the example, "list-style-position", has an "outside"
value. "outside" is the default. One other value is available, "inside".
"outside" causes the hanging indent you see with most lists on web pages.
The label or bullet extends left of the content block and, if the lines wrap,
second and subsequent lines hang to the right and below the label or
A value of "inside" causes the label or bullet to shift toward the right
and to be the first character of the first line of the content block. The
content block is still indented left, like it would be with "outside".
The "list-style-image" property is not in the example above, because it replaces
the "list-style-type" property. To try it, replace
Replace the image URL between the parenthesis with your own. The URL can
be a relative URL or an absolute http://... URL. If you have reason to believe
the location of the image file will change relative to your page, or if your
page is used as a template by a CGI script, an absolute http://... URL is
preferred. With relative URLs, if the relativity changes, then the URL link
The "list-style-image" property lets you use your own image as the bullet
of a list.
Of the browsers I've tested (Windows platform only), all align the bottom
of the image where the bottom of the bullet character would have been. The
image extends upward from there.
One browser I tested (IE 5), displayed the entire image when the image was
wider than the space the bullet character would have used. The beginning
of the text on the first line is shifted toward the right to accommodate
Opera 6 and Netscape 6.2 and 7.0, displayed only the left portion of the
image when the image was wider than the space the bullet character would
Opera 5 and Netscape 4.7 don't recognize the
"list-style-image" property, instead reverting
to the list's default label or bullet.
Because the differences in handling
of images as bullets, I recommend that the images be no wider than the space
the bullet character would have used.
Those are some of the things you can do with list labels and bullets. For
methods of implementing color and images as backgrounds for your lists, see
the two "Cascading Style Sheets (CSS); Backgrounds..." articles linked from
About the Author:
Bontrager Programmer/Publisher, "WillMaster Possibilities"
Are you looking for top quality scripts? Visit
and check out his highly acclaimed Master Series scripts. Some free, some
for a fee.