positioning in ordered lists

positioning in ordered lists

am 24.08.2007 10:07:19 von Stann

Hello,

I'm working with ordered lists. The default list is indented about the same
amount as a

would do. Is there any way to over-ride or tweak
this, so the list is not indented at all? (oops, okay, just changed that
with "text-indent", re-defining the
  • tag. It "un-indents" the list
    items, but only the first text line of each item. other text lines are
    still indented a further "tab" to the right .. :(

    On the same subject, ordered lists contain quite a wide text indent between
    the
      number and the first character of the list item. Seems like about
      a 2-character indent. Is there any way to change this?

      thanks for any help with this...

      Stan

  • Re: positioning in ordered lists

    am 24.08.2007 10:33:03 von dorayme

    In article ,
    "Stann" wrote:

    > Hello,
    >
    > I'm working with ordered lists. The default list is indented about the same
    > amount as a

    would do. Is there any way to over-ride or tweak
    > this, so the list is not indented at all?

    First set

    ul {margin: 0;padding: 0;}

    li {margin: 0;padding: 0;}

    to see the effect. Then you can adjust to your heart's content.

    You do know about css? If you don't and want quick, in the html,
    put:



      and so on.

      Otherwise, put this sort of thing in the head of the document:



      Otherwise and best if you have a more styles, put a link in the
      head to a separate style sheet.

      --
      dorayme

    Re: positioning in ordered lists

    am 24.08.2007 12:22:54 von jkorpela

    Scripsit Stann:

    > I'm working with ordered lists. The default list is indented about
    > the same amount as a

    would do.

    The default indentation for both is 40 pixels, in common practice, though
    lists look different because of the numbers.

    > Is there any way to
    > over-ride or tweak this, so the list is not indented at all?

    Surely. As "dorayme" tells in his/her reply, you can set the margins and
    paddings to zero. However, there's an important side effect: there won't be
    any room for the numbers then.

    Thus, you could set all the margins and paddings to zero _except_
    margin-left for
      (or the
    1. elements), which should be set to a value
      that is sufficient for the number, the period, and the spacing before the
      list item content. This is not exact science, but

      ol, li { margin:0; padding: 0; }
      ol { margin-left: 1.6em; }

      would typically result in "unindented" numbered list. But don't blame me if
      part of the numbers gets chopped off under some circumstances. The only way
      to get exact results (with the usual caveats) is to make the numbers part of
      the content:


      • 1. foo bar
      • 2. zap zap
        ...


      with
      ul, li { margin:0; padding: 0; list-style: none; }

      > (oops, okay, just changed that with "text-indent",

      That might give the illusion of working, until you view the page in a window
      that is narrower than needed to keep each list item on one line. Please
      don't use CSS properties without reading and understanding their _meaning_

      > re-defining the
    2. tag.

      No, the
    3. tag _means_ "list item". There is no
      way you could change this definition. You can use the element against its
      definition but not change its definition.

      > It "un-indents" the list items, but only the first text line of each
      > item. other text lines are still indented a further "tab" to the
      > right .. :(

      Well, yes. You would have known this in advance if...

      > On the same subject, ordered lists contain quite a wide text indent
      > between the
        number and the first character of the list item.
        > Seems like about a 2-character indent. Is there any way to change
        > this?

        Not really in CSS as currently defined and implemented. The tricky way of
        putting numbers into the items would avoid the problem, of course.

        --
        Jukka K. Korpela ("Yucca")
        http://www.cs.tut.fi/~jkorpela/

    Re: positioning in ordered lists

    am 27.08.2007 20:56:07 von Ben C

    On 2007-08-24, Jukka K. Korpela wrote:
    [...]
    > Surely. As "dorayme" tells in his/her reply, you can set the margins and
    > paddings to zero. However, there's an important side effect: there won't be
    > any room for the numbers then.
    >
    > Thus, you could set all the margins and paddings to zero _except_
    > margin-left for

      (or the
    1. elements), which should be set to a value
      > that is sufficient for the number, the period, and the spacing before the
      > list item content. This is not exact science, but
      >
      > ol, li { margin:0; padding: 0; }
      > ol { margin-left: 1.6em; }
      >
      > would typically result in "unindented" numbered list. But don't blame me if
      > part of the numbers gets chopped off under some circumstances. The only way
      > to get exact results (with the usual caveats) is to make the numbers part of
      > the content:

      There is another caveat which is that the 40px margin-left (or
      padding-left) for ol and ul in the default stylesheet is not really
      margin-left but "margin-nearside" or "margin-start", because it turns
      into a right margin if the element's computed value of direction is rtl.

      This isn't in the CSS spec but if browsers didn't do it then simple
      nested lists would look pretty stupid in the right-to-left direction,
      lacking any indentation or space for bullets.

      It's a caveat because if you set margin-left yourself it really does
      mean margin-_left_, not margin-nearside, in browsers I've tried (and I
      agree with this interpretation), and so your lists will look bad if
      their direction is rtl.

      If OP's not using rtl then it doesn't matter.