I have this list:
<ol start="0">
<li>Tokyo Skytree</li>
<li>Canton Tower</li>
<li>CN Tower</li>
<li>Ostankino Tower</li>
<li>Oriental Pearl Tower</li>
</ol>
Which shows something like this:
1. Tokyo Skytree
2. Canton Tower
3. CN Tower
4. Ostankino Tower
5. Oriental Pearl Tower
Now what I want is to have something like this:
[1] Tokyo Skytree
[2] Canton Tower
[3] CN Tower
[4] Ostankino Tower
[5] Oriental Pearl Tower
Ideally I want a 0-based array like:
[0] = Tokyo Skytree
[1] = Canton Tower
[2] = CN Tower
[3] = Ostankino Tower
[4] = Oriental Pearl Tower
I've read about CSS Numbering Style and CSS Lists W3C Draft but I cannot figure out a solution that works.
An ordered list is marked with the numbers by default. You can create an ordered list using the <ol></ol> tag and, define the list items using <li></li>. type="1"− This creates a numbered list starting from 1. type="A"− This creates a list numbered with uppercase letters starting from A.
The OL element defines an ordered list. The element contains one or more LI elements that define the actual items of the list. Unlike with an unordered list (UL), the items of an ordered list have a definite sequence. Items in an ordered list are numbered by the browser.
By default, browsers number ordered list items with a sequence of Arabic numerals. Besides being able to start the sequence at some number other than 1, you can use the type attribute with the <ol> tag to change the numbering style itself.
<ol>: The Ordered List element. The <ol> HTML element represents an ordered list of items — typically rendered as a numbered list.
You can do something like this:
ol {
counter-reset: o-counter -1;
list-style-type: none;
}
ol li:before {
content: '[' counter(o-counter) '] = ';
counter-increment: o-counter;
}
http://jsfiddle.net/userdude/Fb3ab/2/
Keep in mind the o-counter
(or whatever you call it) needs to be on the parent UL
/OL
for it to increment. And, IE7 does not support this either.
More information:
You can use the counter property is CSS.
<ol>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
<li>Vestibulum auctor dapibus neque.</li>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
<li>Vestibulum auctor dapibus neque.</li>
</ol>
ol { list-style: none;
counter-reset:array;}
ol li:before {
counter-increment:array;
content:"[" counter(array) "] ";
}
http://codepen.io/Nunotmp/pen/duhAb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With