Solved

How do I create nested order lists with style type?

Posted on 2014-09-16
7
108 Views
Last Modified: 2014-09-17
How do I do this? Nested <ol><li> styles don't seem to work. Is this not possible with ordered and unordered lists? They all render out as upper-alpha.

A. bla bla bla bla bla bla bla bla bla bla bla bla

B. bla bla bla bla bla bla bla bla bla bla bla bla

   1. bla bla bla bla bla bla bla bla bla bla bla bla

   2. bla bla bla bla bla bla bla bla bla bla bla bla

   3. bla bla bla bla bla bla bla bla bla bla bla bla
      a. bla bla bla bla bla bla bla bla bla bla bla bla

      b. bla bla bla bla bla bla bla bla bla bla bla bla

C. bla bla bla bla bla bla bla bla bla bla bla bla

ol.decimal {
  margin: 0px;
}
	
ol.decimal li {
  list-style-type: decimal;
  margin: 6px 0px;
}
	
ol.upper-alpha {
  margin: 0px;
}
	
ol.upper-alpha li {
  list-style-type: upper-alpha;
  margin: 6px 0px;
}

Open in new window


<ol class="upper-alpha">
<ol class="decimal">
<ol class="lower-alpha">

<ol class="upper-alpha">
	<li>
		bla bla bla bla bla bla bla bla
	</li>
	<li>
		bla bla bla bla bla bla bla bla
		<ol class="decimal>
			<li">
				bla bla bla bla bla bla bla bla
			</li>
			<li>
				bla bla bla bla bla bla bla bla
			</li>
			<li>
				bla bla bla bla bla bla bla bla
			</li>
			<li>
				bla bla bla bla bla bla bla bla
 				<ol class="lower-alpha">
					<li>
						bla bla bla bla bla bla bla bla
					</li>
					<li>
						bla bla bla bla bla bla bla bla
					</li>
				</ol>
			</li>
			<li>
			     bla bla bla bla bla bla bla bla
			</li>
				</ol>
			</li>
		</ol>

Open in new window

0
Comment
Question by:kadin
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:Kim Walker
ID: 40327918
There's very little that you need to change here. Except for a poorly place quote mark on line 12 that belongs on line 11, your list-style-type declarations should be part of the ol style, not the li style.
ol.decimal {
  list-style-type: decimal;
  margin: 0px;
}
	
ol.decimal li {
  margin: 6px 0px;
}
	
ol.upper-alpha {
  list-style-type: upper-alpha;
  margin: 0px;
}
	
ol.upper-alpha li {
  margin: 6px 0px;
}

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

Open in new window

<ol class="upper-alpha">
	<li>
		bla bla bla bla bla bla bla bla
	</li>
	<li>
		bla bla bla bla bla bla bla bla
		<ol class="decimal">
			<li>
				bla bla bla bla bla bla bla bla
			</li>
			<li>
				bla bla bla bla bla bla bla bla
			</li>
			<li>
				bla bla bla bla bla bla bla bla
			</li>
			<li>
				bla bla bla bla bla bla bla bla
 				<ol class="lower-alpha">
					<li>
						bla bla bla bla bla bla bla bla
					</li>
					<li>
						bla bla bla bla bla bla bla bla
					</li>
				</ol>
			</li>
			<li>
			     bla bla bla bla bla bla bla bla
			</li>
		</ol>
	</li>
</ol>

Open in new window

0
 

Author Comment

by:kadin
ID: 40328834
Thanks for your help. I tried what you said. I have tried different combinations. I can only get it to work on two levels, but not three.

Here is what I get.
A.
B.
    1.
    2.
        1.
        2.

Here is what I want.
A.
B.
    1.
    2.
        a. or these could be squares, which I could not get to work either.
        b.
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 40328847
I failed to mention in my previous post that you omitted the style definition for lower-alpha in the css you posted. I added it to the style definitions in my previous comment on lines 19-21. Did you overlook that?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Expert Comment

by:Kim Walker
ID: 40328875
Another way you could define this in css would be to use nested selectors. This way you don't have to worry about adding classes or getting confused and adding the wrong class
ol { list-style-type: decimal; margin: 0px; }
ol li ol { list-style-type: upper-alpha; margin: 0px; }
ol li ol li ol { list-style-type: lower-alpha; }
ol li { margin: 6px 0px; }

Open in new window

<ol>
	<li>
		bla bla bla bla bla bla bla bla
	</li>
	<li>
		bla bla bla bla bla bla bla bla
		<ol>
			<li>
				bla bla bla bla bla bla bla bla
			</li>
			<li>
				bla bla bla bla bla bla bla bla
			</li>
			<li>
				bla bla bla bla bla bla bla bla
			</li>
			<li>
				bla bla bla bla bla bla bla bla
 				<ol>
					<li>
						bla bla bla bla bla bla bla bla
					</li>
					<li>
						bla bla bla bla bla bla bla bla
					</li>
				</ol>
			</li>
			<li>
			     bla bla bla bla bla bla bla bla
			</li>
		</ol>
	</li>
</ol>

Open in new window

Rendering of above HTML
0
 

Author Comment

by:kadin
ID: 40328918
I don't think I forgot anything. I will try your second suggestion in a couple of hours.

ol.lower-alpha {
                list-style-type: lower-alpha;
		margin: 0px;
	}
	
	ol.lower-alpha li {
		margin: 6px 0px;
	}
	
	ol.upper-alpha {
                list-style-type: upper-alpha;
		margin: 0px;
	}
	
	ol.upper-alpha li {
		margin: 6px 0px;
	}
	
	ol.decimal {
                list-style-type: decimal;
		margin: 0px;
	}
	
	ol.decimal li {
		margin: 6px 0px;
	}

Open in new window

0
 
LVL 22

Accepted Solution

by:
Kim Walker earned 500 total points
ID: 40328934
Your styles work fine for me. Can you post a link to your entire page? There could be other styles that are conflicting with these.
0
 

Author Closing Comment

by:kadin
ID: 40329118
That was it. It is working now. This must of had something to do with it. When I disable this, it works.
li {
 list-style-type: none;
}

Thanks for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now