开发者

How can be printed ordered list from number 6 with html only?

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


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.)


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.


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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜