473,387 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Nested Lists

I'm having trouble trying to put 3 definition lists into a unordered list
which has been styled to appear horizontally. My goal is to have the 3
definition lists appear side by side and fill the parent box's width. I've
tried giving the <dtelement a narrow width, allowing room for the all
three, but i've had no success. I'd like, if possible, to do this without
specifying any widths as i'll be conditionally hiding one or maybe two
columns using server side mark-up and i'd like any remaining definition
lists to fill the parent box's width in these cases.

Any ideas if and how this can be acomplished?

Thanks
James
<style type="text/css">
<!--
ul {
margin: 0;
padding: 0;
list-style-type: none;
}
li {
display: inline;
}
-->
</style>

<ul>
<li>
<dl>
<dt>Types</dt>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
</dl>
</li>
<li>
<dl>
<dt>Options</dt>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
</dl>
</li>
<li>
<dl>
<dt>Accessories</dt>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
</dl>
</li>
</ul>
Apr 20 '07 #1
3 2144
On Apr 20, 2:23 pm, "James" <jame...@SPAMgraphics-line.co.ukwrote:
I'm having trouble trying to put 3 definition lists into a unordered list
Looking at your markup, you shouldn't be doing that anyway.

You seem to have three lists each containing one term, instead of one
list containing three terms.

Apr 20 '07 #2
Hi David, thanks for your response
Looking at your markup, you shouldn't be doing that anyway.
Do you mean in terms of being semantically correct or because it will not
work?
You seem to have three lists each containing one term, instead of one
list containing three terms.
Fair enough. Would you care to share with us what css / html you'd use to
accompish the task?

Many Thanks
James
Apr 20 '07 #3
On 2007-04-20, James <ja*****@SPAMgraphics-line.co.ukwrote:
I'm having trouble trying to put 3 definition lists into a unordered list
which has been styled to appear horizontally. My goal is to have the 3
definition lists appear side by side and fill the parent box's width. I've
tried giving the <dtelement a narrow width, allowing room for the all
three, but i've had no success. I'd like, if possible, to do this without
specifying any widths as i'll be conditionally hiding one or maybe two
columns using server side mark-up and i'd like any remaining definition
lists to fill the parent box's width in these cases.

Any ideas if and how this can be acomplished?
The basic problem is you're making li { display: inline; } but then
putting block-level things inside it.

display: inline-block (and setting width on the li) would be perfect. An
inline-block sits on the line but can have block-level things inside it.
An inline box on the other hand can't contain block boxes. Instead
anonymous block boxes are generated around its inline content so you get
a series of block boxes.

Note: I'm talking about the generated CSS boxes here, not the HTML
elements. An HTML element with display: inline can of course contain
elements with display: block, although an HTML element classified as
"inline" in the HTML sense cannot contain elements classified as "block"
in the HTML sense. I am making this sound more confusing than it is.

An example: <em>a<p></p>b</emis invalid HTML. It also happens that
<emis display: inline by default and <pdisplay: block. But
<div>a<div></div>b</divis valid HTML, and I can set display: inline on
the outer <divand display: block on the inner one. That is valid CSS,
but results in the generation of three block boxes: an anonymous one
around "a", one for the inner div, and an anonymous one around "b".

But display: inline-block is not widely supported, so the practical work
around is

li
{
float: left;
width: 200px; /* or something */
}

If you don't set width the lis will be as wide as the screen anyway for
most screens and font-sizes since you've got masses of stuff in those
<dd>s. If you want to divide the screen width evenly between the lis
you've got without setting widths explicitly on them, floats with
percentage widths is an option if you know how many are visible.
Otherwise use a table.
>
<style type="text/css">
<!--
ul {
margin: 0;
padding: 0;
list-style-type: none;
}
li {
display: inline;
}
-->
</style>

<ul>
<li>
<dl>
<dt>Types</dt>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
</dl>
</li>
<li>
<dl>
<dt>Options</dt>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
</dl>
</li>
<li>
<dl>
<dt>Accessories</dt>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
<dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
vel est. Nullam sem pede, porta ut, fermentum sed, rhoncus sed, ante.
Suspendisse pellentesque nisl vel risus. Nam quis arcu in.</dd>
</dl>
</li>
</ul>
Apr 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: chad | last post by:
I am writing a program to do some reliability calculations that require several nested for-loops. However, I believe that as the models become more complex, the number of required for-loops will...
15
by: Xah Lee | last post by:
Here's the belated Java solution. import java.util.List; import java.util.ArrayList; import java.lang.Math; class math { public static List range(double n) { return range(1,n,1); }
0
by: Knepley, Jim | last post by:
I'm basing some work on Joe Celko's excellent idea of using nested sets to represent an organizational structure as opposed to an adjacency list. By and large it's a great idea, but not without its...
7
by: Jane Withnolastname | last post by:
I have a number of unordered lists nested within ULs nested within ULs nested within ULs. I have set the style for LI to be .7em. Mozilla gives me the layout as I imagined it, with the lists...
4
by: Lee K. Seitz | last post by:
I'm still relatively new to stylesheets. I'm trying to do something that seemed fairly simple on the surface, but is proving to be a challenge. I have a set of nested lists: <ul> <li>Side...
6
by: jwvai316 | last post by:
I don't really know how to say it so I just say it a nested linklist. How do you make LinkLists inside LinkList? Can anyone help me for this? I think an example program will help me a lot. ...
2
by: Ben | last post by:
I have some ordered lists, containing unordered lists. I want to double-space the "paragraphs", i.e. ordered lists. But not the the nested lists. I can't figure out how. Page is here:...
7
by: patrick j | last post by:
Hi I'm wondering about lists with nested lists as one does on a Saturday afternoon. Anyway below is an example of a list with a nested list which the iCab browser's very useful HTML...
0
by: mutt1170 | last post by:
I have a checkbox list nested inside a gridview. The gridview pulls its data from an objectdatasource and lists countries. The nested checkbox list is databound to another object datasource and...
7
by: Zethex | last post by:
Im a bit new to python. Anyway working on a little project of mine and i have nested lists ie Answer = , ] and so forth.., Anyway the amount of ] do increase over time. Im just wondering...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.