Forum Moderators: open

Message Too Old, No Replies

Where did start for lists go?

         

coopersita

5:32 pm on Jun 9, 2005 (gmt 0)

10+ Year Member



If you remember, there use to be an html attribute that let you start a list numbering form a number (or letter) other than 1.

<ol start="8">
<li> Starting from 8</li>
</ol>

It seems to have dissapeard from xhtml strict...

Does anyone know of an alternative?

drhowarddrfine

6:36 pm on Jun 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This was deprecated and you aren't allowed to use attributes in xhtml strict. There is no similar attribute in css so off the top of my head I wouldn't know what to tell you.

birdbrain

7:05 pm on Jun 9, 2005 (gmt 0)



Hi there coopersita,

you can cheat with javascript but, of course, it will not work for those who have it disabled. :(


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<title>start at eight</title>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<script type="text/javascript">
//<![CDATA[
function getRound() {
document.getElementById("start").start=8;
}
onload=getRound;
//]]>
</script>

</head>
<body>

<ol id="start">
<li> Starting from 8</li>
<li> This should be nine!</li>
</ol>

</body>
</html>

birdbrain

encyclo

7:12 pm on Jun 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The alternative is to either use XHTML 1.0 Transitional (where it is valid) or use Strict and accept the error. The removal of that attribute was very poorly thought out. Don't sacrifice user experience because the spec is broken. ;)

coopersita

7:44 pm on Jun 9, 2005 (gmt 0)

10+ Year Member



Thanks...

Just as I thought...

Maybe they want us to use css counters instead:

[w3.org...]

But I doubt they are supported by most browsers.

rocknbil

7:58 pm on Jun 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's a hack! :-)

<style type="text/css">
li.dummie { list-style-type:none; display:inline; }
</style>

<ol>
<li class="dummie"></li>
<li class="dummie"></li>
<li class="dummie"></li>
<li>4</li>
<li>5</li>
<li>6</li>
</ol>

But it works . . . .

Robin_reala

6:15 am on Jun 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



CSS counters are your friends here. I believe Opera supports them, and Firefox 1.1 will as well. Obviously IE doesn't.

samuil

9:36 am on Jun 12, 2005 (gmt 0)

10+ Year Member



@Robin_reala

CSS was made to separate content from layout. Using CSS instead of start attribute is using CSS for changing content. I mean: without styles content makes no sense as numbering is wrong.

MatthewHSE

11:58 am on Jun 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Personally, I think the attribute is way more practical for this purpose than CSS pointers. To my understanding, you'd need a separate class for each number you wanted to start a list with. If you needed to use this technique on a number of pages and many different lists, perhaps long lists, you could wind up bloating your stylesheet very quickly and using many unnecessary class names in your document.

Furthermore, using CSS to control list numbering seems like a misuse in the first place. CSS is about presentation, not semantics. Your markup is supposed to supply the semantic meaning of the document, and the number a list starts with is definitely within this realm. It's not presentational; the number has as definite a purpose as a paragraph or a heading.

I'm heart and soul behind CSS for the most part, but sometimes the good old attributes are still the way to go. I consider this one of those cases.

Robin_reala

1:17 pm on Jun 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, I wasn't saying I particulary agree with the use of CSS in this situation.

coopersita

7:17 pm on Jun 13, 2005 (gmt 0)

10+ Year Member



I agree with you, but the w3 seems to think we should use css counters to work around the now deprecated start attribute...

dzinr38

12:32 am on Jun 28, 2005 (gmt 0)



I was just doing some research myself on this subject, and I found this recommendation from the W3C:

Details about number order. In ordered lists, it is not possible to continue list numbering automatically from a previous list or to hide numbering of some list items. However, authors can reset the number of a list item by setting its value attribute. Numbering continues from the new value for subsequent list items. For example:

<ol>
<li value="30"> makes this list item number 30.
<li value="40"> makes this list item number 40.
<li> makes this list item number 41.
</ol>

Here is the URL with information on list ordering. Scroll down about midway and you will find the information I mentioned above: [w3.org...]

It does work, too!

tedster

1:03 am on Jun 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums, dzinr38. That's a nice bit of helpful information for your first post - thanks!

moltar

1:48 am on Jun 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmaster World, dzinr38.

Thank you! I've been passively looking for the solution as well. I am glad there is a way to continue the numbering. I think this is even a better way than it was before.

bill

9:22 am on Jun 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<ol> 
<li value="30"> makes this list item number 30.
<li value="40"> makes this list item number 40.
<li> makes this list item number 41.
</ol>

Outstanding! I hadn't seen that before.

I just tested this out, and it works in all of these:

  • Opera 8
  • IE 6
  • IE 5.5
  • IE 5.01
  • Mozilla 1.7
  • Firefox 1.04
  • Netscape 4.8
  • Netscape 3.04

However, there's a catch...it doesn't validate Strict for HTML 4.01 or XHTML for which the "type" and "value" attributes were depreciated on the <li> element. So, if you're using a Transitional doctype then you could use this or just stick with the old

<ol start="8">
, which will still validate.