Nested Ordered List

C

CK

Hello all,
I have a nested ol and I need help with the numbering.
For example.
<ol>
<li>Sweet</li>
<li>Salty</li>
<ol>
<li>Very Salty</li>
<li>lightly salted</li>
</ol>
<li>bitter</li>
<li>sour</li>
</ol>

I want the output to be
1.. Sweet
2.. Salty
1.1Very Salty
1.2lightly salted
3.. bitter
4.. sour
But it currently renders like this.
1.. Sweet
2.. Salty
1.. Very Salty
2.. lightly salted
3.. bitter
4.. sour
I need the decimal style. Any ideas? Thanks ~CK
 
M

Martin Jay

CK said:
Hello all,
I have a nested ol and I need help with the numbering.
I want the output to be
1.. Sweet
2.. Salty
1.1Very Salty
1.2lightly salted
3.. bitter
4.. sour
But it currently renders like this.
1.. Sweet
2.. Salty
1.. Very Salty
2.. lightly salted
3.. bitter
4.. sour
I need the decimal style. Any ideas? Thanks ~CK

I don't think you can do that without using a script. Couldn't you use
letters, instead?

Also, the HTML you posted was slightly incorrect because you started the
second <ol> inside the first <ol>, but outside an <li>. Try this:

<ol>
<li>Sweet</li>
<li>Salty
<ol style="list-style-type: lower-alpha;">
<li>Very Salty</li>
<li>lightly salted</li>
</ol>
</li>
<li>bitter</li>
<li>sour</li>
</ol>
 
J

Jukka K. Korpela

CK said:
I have a nested ol and I need help with the numbering.

If you really want help, select _the_ group where the question best belongs
to. Crossposting is generally not constructive. Followups randomized as
usual.
I want the output to be
1.. Sweet
2.. Salty
1.1Very Salty
1.2lightly salted

No way. (CSS 2.0 contains tools for generating list markers that way, but
this part was not implemented in browsers and is being phased out in CSS
2.1.)

Use either an unnumbered list, with list-style-type: none in CSS and with
the numbers included into the items themselves, or some other (admittedly
less logical) structure, such as a table.
I need the decimal style.

That's a reasonable request, but browsers won't do it for you.
 
D

dorayme

CK said:
Hello all,
I have a nested ol and I need help with the numbering.
For example.
I need the decimal style. Any ideas? Thanks ~CK

Yes, you need to set the list-style-type. This might do you, I
will give you an inline style for now on the bit that you
probably want different to the normal decimal of the rest:

<ol style="list-style-type: lower-roman">
<li>Very Salty</li>
<li>lightly salted</li>
</ol>
 
D

dorayme

dorayme said:
Yes, you need to set the list-style-type. This might do you, I
will give you an inline style for now on the bit that you
probably want different to the normal decimal of the rest:

<ol style="list-style-type: lower-roman">
<li>Very Salty</li>
<li>lightly salted</li>
</ol>

but it seems it was the decimal numbering you wanted... forget
this, sorry...
 
E

Ed Seedhouse

Hello all,
I have a nested ol and I need help with the numbering.
For example.
<ol>
<li>Sweet</li>
<li>Salty</li>
<ol>
<li>Very Salty</li>
<li>lightly salted</li>
</ol>
<li>bitter</li>

First, you should get your html legal:
<li>Salty
<ol>
<li>Very Salty</li>
<li>lightly salted</li>
</ol>
</li>
<li>bitter</li>

Everthing in an ordered list has to go inside the list items.
 
I

ironcorona

CK said:
I want the output to be
1.. Sweet
2.. Salty
1.1Very Salty
1.2lightly salted
3.. bitter
4.. sour
But it currently renders like this.
1.. Sweet
2.. Salty
1.. Very Salty
2.. lightly salted
3.. bitter
4.. sour
I need the decimal style. Any ideas? Thanks ~CK

I couldn't make it work with a list but in the interests of science I
came up with a sort of hackey workaround.

http://iron.corona.googlepages.com/list_counter.html

As you can see it's not a list any more and it won't work in IE.

Does anyone know when FF started supporting counter-increment? They
didn't quite recently.
 
J

jojo

Martin said:
I don't think you can do that without using a script.

But, of course, you can use a script...
Easiest way would be JavaScript because it's supported by almost every
Browser. The only problem is, that many users switch off JavaScript
because of security-reasons. But if you want to do it with a Script just
tell me, I think I can write you a Script numbering your list as you
requested...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top