Welcome to WebmasterWorld Guest from 54.226.22.192

Forum Moderators: incrediBILL

Message Too Old, No Replies

xhtml 1.1 and "start" or "value" in ordered lists

Can we start with any given number instead of 1?

     
10:06 pm on Feb 3, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 26, 2002
posts:131
votes: 0


Good evening, folks,

I'm trying as hard as I can to keep/convert a tiny site to xhtml 1.1. Now I've faced the trouble of starting an ordered list with a number different from "1". In hmtl I'd say <ol start="2"> or <li value="2"> but this two attributes are deprecated in xhtml 1.1

Some references in the Web seem to point to some CSS way to do that but I'm clueless about it.

Is there any kind sould that could lend me a helping hand in this?

Thanks in advance

gusgsm

10:25 pm on Feb 3, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 4, 2002
posts:5044
votes: 0


Good question!
I couldn't find anything in the CSS2 spec on this. In fact, I didn't even know it could be done ;)

Anyone have the answer?

Nick

10:45 pm on Feb 3, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member suzyuk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Oct 1, 2002
posts:5199
votes: 0


It can be done but not with CSS and XHTML

I have no online reference, but here's a direct quote from a publication (my offline reference!):


  • Q.How do I set the starting values for ordered lists using CSS?
  • A. Unfortunately, you can't set those with CSS. In order to set specific number values for ordered lists, you'll need to use the HTML start attribute on the <ol> element or the value attribute on <li>. Both of these values are deprected in HTML 4.01, which means you can't use them in Strict HTML Documents.
  • So does this mean they're not available for Strict or Transitional XHTML?

    Suzy

    11:31 pm on Feb 3, 2003 (gmt 0)

    Senior Member

    WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

    joined:May 26, 2000
    posts:37301
    votes: 0


    In Section 12.5, this page at the W3C [w3.org] talks about the use of counter-reset. It could be applied to a class of the <ol> element.

    Haven't tried it, so I can't talk about browser support. But in theory, there's the answer.

    11:32 pm on Feb 3, 2003 (gmt 0)

    Full Member

    10+ Year Member

    joined:Mar 25, 2002
    posts:292
    votes: 0


    >>The "compact", "start" and "type" attributes of the ol element are not supported in XHTML 1.0 Strict DTD<<

    From W3Schools.com > OL tag [w3schools.com]

    However, this same page seems to suggest that 'start' is allowed in XHTML Transitional and Frameset DTDs, so maybe Transitional is the way to go?

    I have also seen some of those references to using stylesheets instead, and I too would be interested to find out how this could be done.

    2:08 am on Feb 4, 2003 (gmt 0)

    Senior Member

    WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

    joined:May 26, 2000
    posts:37301
    votes: 0


    I did some browser testing for support of the above scheme. This was my CSS:

    OL{
    counter-reset: item,3;
    }

    LI {
    display: block;
    }

    LI:before {
    content: counters(item, ".");
    counter-increment: item;
    padding-right:8px;
    }

    I notice that support for the :before pseudo element is key to this approach, and that is might scarce right now.

    The only support I found so far is in Opera 7, and it doesn't add the period after the number. But it DOES begin numbering the list items at 4 -- as it should when the reset is set to "3".

    I also tested in Phoenix and IE6 - nada.

    <added>
    As I worked with this, I could see how valuable it will be, if and when it has support. For instance, you could publish a document online and when you added or removed headings, the numbers for them would automatically reset throughout the page. You wouldn't need to deal with that manually at all.
    </added>

    9:37 am on Feb 4, 2003 (gmt 0)

    Junior Member

    10+ Year Member

    joined:Nov 26, 2002
    posts:131
    votes: 0


    Well, thank you all a lot! (specially to tedster).

    Yes that's the CSS2 way. Quite a pity that it does not seem to be implemented yet, but the counter possibilities of the CSS2 seem to be extremely powerful for long legal-like numbered documents.

    Thanks again, folks. Your kindness made my day :)

    PS: I have found (now that I know what I'm looking for) this: [xs4all.nl...]

     

    Join The Conversation

    Moderators and Top Contributors

    Hot Threads This Week

    Featured Threads

    Free SEO Tools

    Hire Expert Members