Ordered Lists <OL>, Starting index with XHTML Strict?

て烟熏妆下的殇ゞ 提交于 2019-11-30 15:38:57
Daan

As kdgregory noted, counters would be the way to accomplish this and still maintain a valid document. This article on Array Studio shows how to code this in XHTML and CSS. The following is copied from their article:

You need to write the following in your CSS:

OL#page_one { counter-reset: item }
OL#page_two { counter-reset: item 5 }
LI { display: block }
LI:before {
    content: counter(item) ". ";
    counter-increment: item;
    display:block;
}

And, this is how your lists should be defined:

<ol id="page_one">
    <li>Division Bell</li>
    <li>Atom Hearth Mother</li>
    <li>Relics</li>
    <li>Dark Side of the Moon</li>
    <li>Wish You Were Here</li>
</ol>

<ol id="page_two">
    <li>The Wall</li>
    <li>More</li>
    <li>Piper at the gates of Dawn</li>
    <li>Final Cut</li>
    <li>Meddle</li>
</ol>

You could definitely use counters but maybe a more practical solution would be to use an XHTML Transitional doctype. I know this doesn't answer your question but this is one of those situations where you can end up coding up the walls and across the ceiling to do something that doesn't gain you much.

The CSS solution is to use a list counter: http://www.w3.org/TR/CSS2/generate.html#counters

And it seems that, to support paging, you could simply put a hardcoded <style> element into the <head>, or set the style explicitly on the element (haven't tried either, so ymmv).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!