473,467 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

List item distance

Hi,

Is there a way to set the distance between the items in a list that I can
put in the <ul> or <ol> tag?

I suppose that using margin in the <li> tag will work but the endless
repetition seems to me rather unelegant and a waste of bandwidth.

I don't use a stylesheet file, but want to implement it with "style=" in the
tag.

Thanks,
Wim
Jul 21 '05 #1
14 9628
"Wim Roffil" <wimroffel@please_no_spam-planet.nl> writes:
Is there a way to set the distance between the items in a list that I can
put in the <ul> or <ol> tag?

I suppose that using margin in the <li> tag will work but the endless
repetition seems to me rather unelegant and a waste of bandwidth.

I don't use a stylesheet file, but want to implement it with "style=" in the
tag.


This can only be done without repetition in a stylesheet. It can't be
done with style attributes on a tag.

li { ... } /* All li */
ul.reasons li { ... } /* All li in a <ul class="reasons"> */

This is why a stylesheet is the best approach.

Is there any reason you can't use a stylesheet file? A second-best
approach is to put an inline stylesheet in the HTML. It's still
unnecessary repetition, though, if it's at all avoidable.

--
Chris
Jul 21 '05 #2
Wim Roffil wrote:
Hi,

Is there a way to set the distance between the items in a list that I can
put in the <ul> or <ol> tag?

I suppose that using margin in the <li> tag will work but the endless
repetition seems to me rather unelegant and a waste of bandwidth.

I don't use a stylesheet file, but want to implement it with "style=" in the
tag.

Thanks,
Wim

I suggest using a style block in the head element, but why you do not
want to use a stylesheet file when you are concerned with bandwith usage
and elegancy is a mystery to me.

Try this:

<!DOCTYPE ... your doctype declaration ...>
<html>
<head>
< .. your head tags.. >
<style>
li {margin-left: 0.5em;}
</style>
</head>
<body>
<ul>
<li>Listitem with 0.5em left margin</li>
<li>Listitem with 0.5em left margin</li>
<li>Listitem with 0.5em left margin</li>
<li>Listitem with 0.5em left margin</li>
</ul>
</body>
</html>
Jul 21 '05 #3
in comp.infosystems.www.authoring.stylesheets, Wim Roffil wrote:
Hi,

Is there a way
Yes.
I suppose that using margin in the <li> tag will work
Yes
but the endless
repetition seems to me rather unelegant and a waste of bandwidth.
Yes
I don't use a stylesheet file, but want to implement it with "style=" in the


You know solution good solution, you know bad solution, and you don't
want to use good solution, but bad one. There is nothing we can do.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
Jul 21 '05 #4
saz
In article <d0**********@reader13.wxs.nl>, wimroffel@please_no_spam-
planet.nl says...
Hi,

Is there a way to set the distance between the items in a list that I can
put in the <ul> or <ol> tag?

I suppose that using margin in the <li> tag will work but the endless
repetition seems to me rather unelegant and a waste of bandwidth.

I don't use a stylesheet file, but want to implement it with "style=" in the
tag.

Thanks,
Wim

Hard way, add to each tag:

<li style="line-height:1em;">

Easier way - Add line height or margin to the style tags within the head
tags:

<style type="text/css">
<!--
li { line-height:1em; }
-->
</style>

or

<style type="text/css">
<!--
li { margin-top:1em; }
-->
</style>

Use a stylesheet. It's much easier and changes will be global. What if
you add this list to another page? You'd have to redo this on the new
page.
Jul 21 '05 #5
in comp.infosystems.www.authoring.stylesheets, saz wrote:
In article <d0**********@reader13.wxs.nl>, wimroffel@please_no_spam-
planet.nl says...
Hi,

Is there a way to set the distance between the items in a list that I can
put in the <ul> or <ol> tag?
Hard way, add to each tag:

<li style="line-height:1em;">


Why are you using line height? It means space between lines. That
includes also between lines in list item, which is not wanted:

* foobar akdfnlsk fnsrke gre

re esfrks rkesh seht ge

* jdsfbskfzsbvfk

When line-height:2. Better:

* foobar akdfnlsk fnsrke gre
re esfrks rkesh seht ge

* jdsfbskfzsbvfk

This is with margin: 1em 0;

Much better to use margin. (and in case of using line height, it would
make more sence to use it for ul or ol...)
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
Jul 21 '05 #6
saz
In article <MP************************@news.individual.net> ,
la***@raittila.cjb.net says...
in comp.infosystems.www.authoring.stylesheets, saz wrote:
In article <d0**********@reader13.wxs.nl>, wimroffel@please_no_spam-
planet.nl says...
Hi,

Is there a way to set the distance between the items in a list that I can
put in the <ul> or <ol> tag?

Hard way, add to each tag:

<li style="line-height:1em;">


Why are you using line height? It means space between lines. That
includes also between lines in list item, which is not wanted:

* foobar akdfnlsk fnsrke gre

re esfrks rkesh seht ge

* jdsfbskfzsbvfk

When line-height:2. Better:

* foobar akdfnlsk fnsrke gre
re esfrks rkesh seht ge

* jdsfbskfzsbvfk

This is with margin: 1em 0;

Much better to use margin. (and in case of using line height, it would
make more sence to use it for ul or ol...)

I was just giving options. I've used both, and choose by what gives the
better results.
Jul 21 '05 #7

"saz" <sa*****@nospammersexcite.com> schreef in bericht
news:MP***********************@news.comcast.gigane ws.com...
<style type="text/css">
<!--
li { margin-top:1em; }
-->
</style>
I was hoping this could be translated in the tag in something like <ol
style="li.margin-height:1em">
Use a stylesheet. It's much easier and changes will be global. What if
you add this list to another page? You'd have to redo this on the new
page.


I have a big website with one stylesheet. This style element is for one
rather small category. I don't think that every exception should be loaded
into the stylesheet.

Wim
Jul 21 '05 #8
On Fri, 11 Mar 2005, saz wrote:
<style type="text/css">
<!--
li { line-height:1em; }
-->
</style>


Don't include the faux "comment" markers if you're trying to write
XHTML.

Even in HTML, this feature is ancient history by now. Browsers were
at least *understanding* how to parse a style element by HTML/3.2 at
the latest (even those which didn't choose to support stylesheets).
The old browser/versions which still would need the "comment" markers
pre-date the introduction of the Host: header in HTTP requests, so
such browsers would be practically useless on today's web anyway.

Preferably, anyway, use an external stylesheet.
Jul 21 '05 #9
"Wim Roffil" <wimroffel@please_no_spam-planet.nl> writes:
"saz" <sa*****@nospammersexcite.com> schreef in bericht
news:MP***********************@news.comcast.gigane ws.com...
Use a stylesheet. It's much easier and changes will be global. What if
you add this list to another page? You'd have to redo this on the new
page.


I have a big website with one stylesheet. This style element is for one
rather small category. I don't think that every exception should be loaded
into the stylesheet.


Inside that category, and only in the pages in that category, have
<link rel="stylesheet" type="text/css" href="/css/main-stylesheet.css">
<link rel="stylesheet" type="text/css" href="/css/category4-stylesheet.css">

Outside the category, just have
<link rel="stylesheet" type="text/css" href="/css/main-stylesheet.css">

The category specific stylesheet contains the exceptions. If your site
generation tool doesn't let you have a slightly different template for
that section, it's time to get a better site generation tool.

Note that, unless the exceptions are quite large - 5k of CSS or more,
perhaps - you're probably better just putting them in the main
stylesheet.

--
Chris
Jul 21 '05 #10
saz
In article <d0**********@reader08.wxs.nl>, wimroffel@please_no_spam-
planet.nl says...

"saz" <sa*****@nospammersexcite.com> schreef in bericht
news:MP***********************@news.comcast.gigane ws.com...
<style type="text/css">
<!--
li { margin-top:1em; }
-->
</style>


I was hoping this could be translated in the tag in something like <ol
style="li.margin-height:1em">
Use a stylesheet. It's much easier and changes will be global. What if
you add this list to another page? You'd have to redo this on the new
page.


I have a big website with one stylesheet. This style element is for one
rather small category. I don't think that every exception should be loaded
into the stylesheet.

Wim

Why not? That's why you have a stylesheet. Add a class for this list.

<div class="list">
<ol>
<li>item1</li>
<li>item 2</li>
</ol>
</div>

or use <ol class="list"> either way will work

Add to your stylesheet:

..list li{ margin-top:1em; }

Why are you trying to make it more difficult than it has to be?
Jul 21 '05 #11
*saz* <sa*****@nospammersexcite.com>:

Why not? That's why you have a stylesheet. Add a class for this list.
ACK.
<div class="list"><ol>(...)
or use <ol class="list"> either way will work


Why the "or"? Why would one add yet another superfluous 'div' just to add
a class?

--
"You cannot make a man by standing a sheep on its hind legs.
But by standing a flock of sheep in that position you can make a crowd of men."

Max Beerbohm
Jul 21 '05 #12
saz
In article <op**************@crissov.de>,
ch**************@nurfuerspam.de says...
*saz* <sa*****@nospammersexcite.com>:

Why not? That's why you have a stylesheet. Add a class for this list.


ACK.
<div class="list"><ol>(...)
or use <ol class="list"> either way will work


Why the "or"? Why would one add yet another superfluous 'div' just to add
a class?

Because the OP seems to prefer the hard way of doing this.
Jul 21 '05 #13
saz
In article <Pi******************************@ppepc56.ph.gla.a c.uk>,
fl*****@ph.gla.ac.uk says...
On Fri, 11 Mar 2005, saz wrote:
<style type="text/css">
<!--
li { line-height:1em; }
-->
</style>


Don't include the faux "comment" markers if you're trying to write
XHTML.

Even in HTML, this feature is ancient history by now. Browsers were
at least *understanding* how to parse a style element by HTML/3.2 at
the latest (even those which didn't choose to support stylesheets).
The old browser/versions which still would need the "comment" markers
pre-date the introduction of the Host: header in HTTP requests, so
such browsers would be practically useless on today's web anyway.


Old habits die hard. I just automatically add the comments. I can't
remember the last time I put style in the head tags, so I guess I should
erase it from memory.
Jul 21 '05 #14
Wim Roffil wrote:
"saz" <sa*****@nospammersexcite.com> schreef in bericht
news:MP***********************@news.comcast.gigane ws.com...
<style type="text/css">
<!--
li { margin-top:1em; }
-->
</style>

I was hoping this could be translated in the tag in something like <ol
style="li.margin-height:1em">
Use a stylesheet. It's much easier and changes will be global. What if
you add this list to another page? You'd have to redo this on the new
page.

I have a big website with one stylesheet. This style element is for one
rather small category. I don't think that every exception should be loaded
into the stylesheet.

Wim

There is another option:

<link rel="stylesheet" type="text/css" href="/css/category4-stylesheet.css">

The first line in category4-stylesheet.css
@import url(main-stylesheet.css)

all styles in category-4 sheet will override main.
Jul 21 '05 #15

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

Similar topics

12
by: Brett L. Moore | last post by:
Hi, I have had trouble determining whether the STL list.size() operation is O(1) or O(n). I know the list is a doubly-linked list, so if the size() operation begins at the head, then counts to...
4
by: Jeff Thies | last post by:
I'd like to return two values from a function. I'm doing this: function getTwo(){ // some code return new Array(value_a,value_b); } var returnArray=getTwo(some_var); var...
1
by: maxmarengo | last post by:
I am trying to write a query in Access (or SQL) that works on a table like this: Location Gridreference Ben Nevis NQ1234512345 Ben Doon NQ1230012300 and so on for several thousand...
24
by: Robin Cole | last post by:
I'd like a code review if anyone has the time. The code implements a basic skip list library for generic use. I use the following header for debug macros: /* public.h - Public declarations and...
8
by: MJ | last post by:
Hi I have a question I have a singly linked list of 10 elements. I have to find the Nth (Ex 3rd element from the end) element from the end. What are the ways to do it with less complexity I...
5
by: JustSomeGuy | last post by:
According to the docs... http://www.cppreference.com/cpplist/sort.html There is a parameter to the std::list.sort method. I don't understand this methods use... I want to sort the list which...
10
by: charles.hebert | last post by:
Hi, Can anybody tell me how to to find the nearest value to zero in a list ? To do that, i'm using list comprenhension : Something simpler ?
21
by: bilgekhan | last post by:
After doing a succcessful insert() or find() on a set<Tcontainer is it possible to get the item number of this item in the set? (ie. its zero-based sequence number (position/location/rank/index)...
0
by: Gabriel Genellina | last post by:
En Fri, 26 Sep 2008 01:42:59 -0300, Chris Rebert <clp@rebertia.com> escribió: I think the above expression is overcomplicated. The code below does the exact same thing and is easier to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.