Solved

How do I create nested order lists with style type?

Posted on 2014-09-16
7
112 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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…

630 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