SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: List Numbering

  1. #1
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    List Numbering

    I've got a list that needs to be numbered, and also have sub lists that are numbered, however I've got a slight problem in the way that the lists are being numbered.

    Currently they are numbered as follows:

    1. List Item One
    1. Sub-list Item One
    2. Sub-list Item Two
    2. List Item Two
    1. Sub-list Item One
    1. Sub-sub-list Item One
    2. Sub-list Item Two
    3. List Item Three
    1. Sub-list Item One
    2. Sub-list Item Two
    Ideally I want the list to be numbered as follows:

    1. List Item One
    1.1. Sub-list Item One
    1.2. Sub-list Item Two
    2. List Item Two
    2.1. Sub-list Item One
    2.1.1. Sub-sub-list Item One
    2.2. Sub-list Item Two
    3. List Item Three
    3.1. Sub-list Item One
    3.2. Sub-list Item Two
    The code I'm using is as follows:

    HTML Code:
    <ol>
    <li>List Item One</li>
    <ol>
    <li>Sub-list Item One</li>
    <li>Sub-list Item Two</li>
    </ol>
    <li>List Item Two</li>
    <ol>
    <li>Sub-list Item One</li>
    <ol>
    <li>Sub-sub-list Item One</li>
    </ol>
    <li>Sub-list Item Two</li>
    </ol>
    <li>List Item Three</li>
    <ol>
    <li>Sub-list Item One</li>
    <li>Sub-list Item Two</li>
    </ol>
    </ol>
    James Maskell
    Prime Hosting Limited
    UK Company Reg No: 05360382
    www.primehosting.co.uk

  2. #2
    \m/\m/ karinne's Avatar
    Join Date
    Dec 2002
    Location
    Aylmer, QC, Canada
    Posts
    409
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It should be like this

    Code:
    <ol>
        <li>List Item One     <------------ note the </li> closed below
            <ol>
                <li>Sub-list Item One</li>
                <li>Sub-list Item Two</li>
            </ol></li>     <------------------- here
        <li>List Item Two
            <ol>
                <li>Sub-list Item One
                    <ol>
                        <li>Sub-sub-list Item One</li>
                    </ol></li>
                <li>Sub-list Item Two</li>
            </ol></li>
        <li>List Item Three
            <ol>
                <li>Sub-list Item One</li>
                <li>Sub-list Item Two</li>
            </ol></li>
    </ol>
    As for the numbering, you check the big discussion we had not too long ago about the start attribute

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't achieve list numbering like 1.1 using HTML only. It's a presentational matter, so it should be controlled via CSS. Unfortunately few browsers support CSS 2.1 to this extent; I know Opera does, and I think Safari does too, but AFAIK that's it.
    Birnam wood is come to Dunsinane

  4. #4
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    (Firefox supports counters too, since 1.5.)
    Simon Pieters

  5. #5
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And Konqueror 3 (I still haven't tested it in 3.3 yet) but not Safari 2.0.

    From the thread karinne linked to:
    Quote Originally Posted by Kravvitz
    Actually Mozilla 1.8+ and Konqueror 3 (tested in 3.4+) support the CSS2 way to do this too. iCab 3 may support it as well. If anyone wants to see my test page, just ask and I'll be happy to make it publicly available.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •