View Full Version : list-style-type alternatives?

08-09-2005, 04:49 PM

Two Questions:

1 (this is more important):

How do I continue list numbering (or lettering) from one list to another?



<p>Rhubarb, rhubarb, rhubarb</p>

<ol> <!-- I would like this to continue numbering at "4" rather than reverting to "1". -->

If you specify list-style-type:lower-alpha;, your bullets look like:

a. Banana
b. Colobus
c. Howler
d. Macaque

What I would like is:

(a) Banana
(b) Colobus
(c) Howler
(d) Macaque

Is there a way of doing this with CSS list style specifiers?

If the simple answer is "no", then I can live with that restriction!

Incidentally, I have tried using the examples given in the CSS2 specification (http://www.w3.org/TR/REC-CSS2/generate.html#markers) - but they don't work! Even when I do a direct cut-and-paste of the example into an HTML document! This is really irritating because the examples show exactly what I am trying to do. I am using IE version 6.


08-09-2005, 05:51 PM
1. You can use a 'start' attribute to specify where to start counting at. I don't know if/think there is a CSS option.


<ol start="4">

2. I believe you can use the 'content:before' and 'after' properties, although I haven't played with it much so can't really help you too much.


li:before {content: "("}
li:after {content: ")"}

Try it and let me know how it goes... but thinking about it, the 'after' one probably places it at the end of the list, and the before one may place it after the 'a.' ! :)

08-09-2005, 05:57 PM
Yep, I tried that, doesn't work! (see my additional comments on my original post). Perhaps I'm doing something wrong somewhere ... !

08-09-2005, 06:24 PM
Yup strange doesn't work in FF or IE... :confused:

Grant Palin
08-09-2005, 06:25 PM
You should know that IE6 does not have a complete CSS implementation (far from it!), and in particular does not support :before and :after. But it will work in newer browsers such as Mozilla and Firefox.

IE7 is in beta right now, and will supposedly add support for the more commonly used CSS elements, hopefully including :before.

08-09-2005, 06:32 PM
You should know that IE6 does not have a complete CSS implementation

I though that would be the case, didn't work in FF though.

Grant Palin
08-09-2005, 07:46 PM
Hmmm...Might be the symbols you were trying to use. Admittedly, I don't know enough about using :before with FireFox, but I was able to use a single symbol for fancy list bullets on my website. Don't know about this case, though.

08-09-2005, 07:52 PM
I had a feeling it might be something to do with unsupported stuff!

Well, at least I can do it in PHP instead!


08-11-2005, 04:32 PM
Done it in PHP! :thumbsup:

It's as ugly as sin (the code, that is, not the auto-generated HTML! - the word "hack" springs to mind ...) - but it works! :D

08-11-2005, 11:49 PM
There are always CSS Generated Counters, but they don't work in IE.

ol {
list-style-type: none;

ol li:before {
content: "(" content: counter(ol, lower-alpha) ") ";
counter-increasement: ol 1;

I didn't see the last part of your first post. So, ignore this.