Start a list from a certain number

冷暖自知 提交于 2019-12-12 19:18:52

问题


What's the best way to get a ol to start from 'x'?

The start tag is deprecated and everything I have found on Google has used the :before pseudo class which doesn't work in IE6 or 7. Didn't have much luck when searching stack either.

Only thing I can think of is manually go through and number the lists myself and style accordingly?

Any help appreciated.


回答1:


While the start attribute in HTML 4 is indeed deprecated, looking at the HTML 5 docs, I see:

The start attribute, if present, must be a valid integer giving the ordinal value of the first list item.

If the start attribute is present, user agents must parse it as an integer, in order to determine the attribute's value. The default value, used if the attribute is missing or if the value cannot be converted to a number according to the referenced algorithm, is 1 if the element has no reversed attribute, and is the number of child li elements otherwise.

The first item in the list has the ordinal value given by the ol element's start attribute, unless that li element has a value attribute with a value that can be successfully parsed, in which case it has the ordinal value given by that value attribute.

which tells me I am safe using start with ol and value with li elements.




回答2:


With ordered lists ol, you could use the various counter CSS instructions: Examples here. But, they also won't work with IE6 and 7. I don't think there is a non-Javascript way to make this work in them.



来源:https://stackoverflow.com/questions/2496158/start-a-list-from-a-certain-number

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