List item distance

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wim Roffil

    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


  • Chris Morris

    #2
    Re: List item distance

    "Wim Roffil" <wimroffel@plea se_no_spam-planet.nl> writes:[color=blue]
    > 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.[/color]

    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

    Comment

    • Ståle Sæbøe

      #3
      Re: List item distance

      Wim Roffil wrote:[color=blue]
      > 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
      >
      >[/color]
      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>

      Comment

      • Lauri Raittila

        #4
        Re: List item distance

        in comp.infosystem s.www.authoring.stylesheets, Wim Roffil wrote:[color=blue]
        > Hi,
        >
        > Is there a way[/color]

        Yes.
        [color=blue]
        > I suppose that using margin in the <li> tag will work[/color]

        Yes
        [color=blue]
        > but the endless
        > repetition seems to me rather unelegant and a waste of bandwidth.[/color]

        Yes
        [color=blue]
        > I don't use a stylesheet file, but want to implement it with "style=" in the[/color]

        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.

        Comment

        • saz

          #5
          Re: List item distance

          In article <d0s87f$kfg$1@r eader13.wxs.nl> , wimroffel@pleas e_no_spam-
          planet.nl says...[color=blue]
          > 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
          >[/color]
          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.

          Comment

          • Lauri Raittila

            #6
            Re: List item distance

            in comp.infosystem s.www.authoring.stylesheets, saz wrote:[color=blue]
            > In article <d0s87f$kfg$1@r eader13.wxs.nl> , wimroffel@pleas e_no_spam-
            > planet.nl says...[color=green]
            > > 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?[/color][/color]
            [color=blue]
            > Hard way, add to each tag:
            >
            > <li style="line-height:1em;">[/color]

            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.

            Comment

            • saz

              #7
              Re: List item distance

              In article <MPG.1c9bcae38a a8041898a3d0@ne ws.individual.n et>,
              lauri@raittila. cjb.net says...[color=blue]
              > in comp.infosystem s.www.authoring.stylesheets, saz wrote:[color=green]
              > > In article <d0s87f$kfg$1@r eader13.wxs.nl> , wimroffel@pleas e_no_spam-
              > > planet.nl says...[color=darkred]
              > > > 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?[/color][/color]
              >[color=green]
              > > Hard way, add to each tag:
              > >
              > > <li style="line-height:1em;">[/color]
              >
              > 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...)
              >
              >
              >[/color]
              I was just giving options. I've used both, and choose by what gives the
              better results.

              Comment

              • Wim Roffil

                #8
                Re: List item distance


                "saz" <saz1958@nospam mersexcite.com> schreef in bericht
                news:MPG.1c9b63 999e99513989733 @news.comcast.g iganews.com...[color=blue]
                > <style type="text/css">
                > <!--
                > li { margin-top:1em; }
                > -->
                > </style>[/color]

                I was hoping this could be translated in the tag in something like <ol
                style="li.margi n-height:1em">
                [color=blue]
                > 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.[/color]

                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


                Comment

                • Alan J. Flavell

                  #9
                  Re: List item distance

                  On Fri, 11 Mar 2005, saz wrote:
                  [color=blue]
                  > <style type="text/css">
                  > <!--
                  > li { line-height:1em; }
                  > -->
                  > </style>[/color]

                  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.

                  Comment

                  • Chris Morris

                    #10
                    Re: List item distance

                    "Wim Roffil" <wimroffel@plea se_no_spam-planet.nl> writes:[color=blue]
                    > "saz" <saz1958@nospam mersexcite.com> schreef in bericht
                    > news:MPG.1c9b63 999e99513989733 @news.comcast.g iganews.com...[color=green]
                    > > 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.[/color]
                    >
                    > 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.[/color]

                    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

                    Comment

                    • saz

                      #11
                      Re: List item distance

                      In article <d0sef8$2he$1@r eader08.wxs.nl> , wimroffel@pleas e_no_spam-
                      planet.nl says...[color=blue]
                      >
                      > "saz" <saz1958@nospam mersexcite.com> schreef in bericht
                      > news:MPG.1c9b63 999e99513989733 @news.comcast.g iganews.com...[color=green]
                      > > <style type="text/css">
                      > > <!--
                      > > li { margin-top:1em; }
                      > > -->
                      > > </style>[/color]
                      >
                      > I was hoping this could be translated in the tag in something like <ol
                      > style="li.margi n-height:1em">
                      >[color=green]
                      > > 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.[/color]
                      >
                      > 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
                      >
                      >
                      >[/color]
                      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?

                      Comment

                      • Christoph Paeper

                        #12
                        Re: List item distance

                        *saz* <saz1958@nospam mersexcite.com> :[color=blue]
                        >
                        > Why not? That's why you have a stylesheet. Add a class for this list.[/color]

                        ACK.
                        [color=blue]
                        > <div class="list"><o l>(...)
                        > or use <ol class="list"> either way will work[/color]

                        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

                        Comment

                        • saz

                          #13
                          Re: List item distance

                          In article <opsnhexvcdb8p2 44@crissov.de>,
                          christoph.paepe r@nurfuerspam.d e says...[color=blue]
                          > *saz* <saz1958@nospam mersexcite.com> :[color=green]
                          > >
                          > > Why not? That's why you have a stylesheet. Add a class for this list.[/color]
                          >
                          > ACK.
                          >[color=green]
                          > > <div class="list"><o l>(...)
                          > > or use <ol class="list"> either way will work[/color]
                          >
                          > Why the "or"? Why would one add yet another superfluous 'div' just to add
                          > a class?
                          >
                          >[/color]
                          Because the OP seems to prefer the hard way of doing this.

                          Comment

                          • saz

                            #14
                            Re: List item distance

                            In article <Pine.LNX.4.61. 0503111529470.6 170@ppepc56.ph. gla.ac.uk>,
                            flavell@ph.gla. ac.uk says...[color=blue]
                            > On Fri, 11 Mar 2005, saz wrote:
                            >[color=green]
                            > > <style type="text/css">
                            > > <!--
                            > > li { line-height:1em; }
                            > > -->
                            > > </style>[/color]
                            >
                            > 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.
                            >[/color]

                            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.

                            Comment

                            • Ståle Sæbøe

                              #15
                              Re: List item distance

                              Wim Roffil wrote:[color=blue]
                              > "saz" <saz1958@nospam mersexcite.com> schreef in bericht
                              > news:MPG.1c9b63 999e99513989733 @news.comcast.g iganews.com...
                              >[color=green]
                              >><style type="text/css">
                              >><!--
                              >>li { margin-top:1em; }
                              >>-->
                              >></style>[/color]
                              >
                              >
                              > I was hoping this could be translated in the tag in something like <ol
                              > style="li.margi n-height:1em">
                              >[color=green]
                              >>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.[/color]
                              >
                              >
                              > 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
                              >
                              >[/color]
                              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.

                              Comment

                              Working...