Solved

How do I create nested order lists with style type?

Posted on 2014-09-16
7
109 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

822 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