Forum Moderators: not2easy

Message Too Old, No Replies

Nested <ol> not incrimenting correctly

         

flycast

4:41 pm on Nov 23, 2007 (gmt 0)

10+ Year Member



I have nested ordered lists. They should look like this:

1. English
a. English
b. Jinglish
c. Spanglish
d. Geek
2. Jinglish
3. Spanglish
4. Geek

but instead look like this:

1. English
1. English
2. Jinglish
3. Spanglish
4. Geek
2. Jinglish
3. Spanglish
4. Geek

(no a..d)

My html:


<ol>

<li>English</li>

<ol>
<li>English</li>
<li><a href="site_url}">Jinglish</a></li>
<li>Spanglish</li>
<li>Geek</li>
</ol>

<li><a href="site_url}">Jinglish</a></li>
<li>Spanglish</li>
<li>Geek</li>
</ol>


My CSS:


#LHContent ol{
margin-bottom: 19px;
list-style-position: inside;
margin-left: 10px;
list-style-type: decimal;
}

Before you ask... the ol is inside a div with the id="LHContent"

willybfriendly

5:02 pm on Nov 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ON the nested list, try

list-style-type: lower-alpha;

Xapti

5:08 pm on Nov 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Exactly. Nested lists don't automatically change their list type, as far as I know, so you should specify for ol ol{}

flycast

6:37 pm on Nov 23, 2007 (gmt 0)

10+ Year Member



So you are both saying that nested lists dont automatically indent and change list styles? That means that for every sub level I will need to create a class for that particular sub level?

willybfriendly

7:16 pm on Nov 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you will need a class for every sublevel.

Many ways to style a list - alpha (caps or lower) Roman (caps or lower) Arabic, etc. THere is no way for the browser to determine the intent of the designer if it isn't explicitly stated.

rocknbil

10:50 pm on Nov 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That means that for every sub level I will need to create a class for that particular sub level?

You don't need to create a new class, but you do need to create a new selector. A less complicated approach is suggested by Xapti here:

ol ol{}

To expand on this, apply willyB's suggestion:

ol ol li { list-style-type: lower-alpha; }

So now you have the first ordered list inside any ordered list, the list items will be alpha. This allows you to create your OL's in your HTML uncluttered by unnecessary classes.

EDIT: Untested, in afterthought you MAY need to do this: "ol li ol li" - because the nested list is actually inside the LI's of the outer list.

willybfriendly

11:30 pm on Nov 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ol li ol li

That's what I love about this place. I learn things daily!