views:

66

answers:

4

Hi,

How can be printed ordered list from number 6 with html only (if its not possible how should be done)?

Example:

6.home

7.place

8.etc..

9.etc..

Thanks

+1  A: 

Are you asking for the syntax for

<ol start="6">
  <li></li>
  <li></li>
</ol>

However, according to w3.org the start value is deprecated on OL...

drachenstern
+7  A: 

Use the start attribute:

<ol start=6>
  <li>home</li>
  <li>place</li>
  ...
</ol>

Note that its use is deprecated so you shouldn't use it in new documents. The W3C recommends replacing its use by CSS Counters.

(In my humble opinion though, this is partially a mistake, since the number with which a list starts isn't always a pure style choice. Numbered lists carry semantics as well and in this case I consider a number to start with semantics, not style.)

Joey
However, counting is not content. It's still a styling concern, as most people who are worried about actively attaching a number to something have already done the counting, they instead want to draw attention to the position in a list. Additionally, people tend to STYLE their numbers differently than the content. I think this is still a valid CSS concern. I also trust that the guys who make these decisions have years more experience and they have polled many more than than just you or I on the matter.
drachenstern
Well, another problem is that I have rarely seen CSS counters in action. IE tended to not support them anyway until version 7 or 8 (probably 8) and many sites just generate numberings server-side.
Joey
@Johannes Rössel ~ And hence there's still support for it, but I think that authors who are looking to use numbering as they do drop-caps will use the CSS styling, and automated generators will either be upgraded or continue to rely on the brute force method for `start=` ~ I don't expect this support to be dropped, altho it's entirely possible rendering engines will on the fly convert `start=` in the future to CSS styling. That may be the best way in the future to handle deprecated tags with direct upgrade portability.
drachenstern
FYI, the start attribute seems to be back to it's former glory in HTML5: http://www.w3.org/TR/html5/grouping-content.html#the-ol-element
Olly Hodgson
@Olly Hodgson ~ But that's just the working draft, so the official status is deprecated. But I'm with @Johannes on this one, would prefer to see it stay in, if only for continued support.
drachenstern
Well, continued support doesn't bite you in any case. Browser vendors will support HTML 4 just fine, even if HTML 5 is final some day.
Joey
+2  A: 

An alternative way in HTML only is:

<ol>
<li value="6">test</li>
<li>This should be 7</li>
</ol>

This allows more flexibility since you can reset numbering mid list but it is still deprecated. As Johannes Rössel said you should use CSS methods if possible.

Chris
A: 

This solution may not look efficient but it works (only in IE). This way you don't have to use the deprecated start attribute.

CSS code:

.hideme { display:inline;}

HTML code:

<ol id="num">
    <li class="hideme"></li>
    <li class="hideme"></li>
    <li class="hideme"></li>
    <li class="hideme"></li>
    <li class="hideme"></li>    
    <li>home</li>
    <li>place</li>
    <li>etc</li>
    <li>etc</li>
    <li>etc</li>
    <li>..</li>
</ol>

Though it works, I feel it's ugly.

Vijey
display:none instead should works better
Yosef
+1 for effort, -1 for not really sticking to anything reasonable... what if you wanted to start your list at 545? You would have a lot of text transferred for no reason ... As already pointed out, it's not quite deprecated, and most browsers have no problem still observing the rule.
drachenstern
Hi drachenstern,I agree with your comments. As I pointed out earlier, it's ugly. However, I just want to share the following points with you:1) This idea can be used from a client-side JS framework (like JQuery). 2) This approach should not be done at server side and transfer the markup to client side. As this require a lot of text transferred (as correctly pointed by you).3) This approach should not be done for a long list. (say 545 as mentioned by you).4) This approach can be used in extreme cases where you have to use the strict doctype for your xhtml.
Vijey