Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom ordered list format

Tags:

html

I tried to use ordered list <ol> and each list item <li> outputs as 1. 2. 3. ... etc, I want the output to be 1) 2) 3) ... etc, can this be done?

like image 308
sikas Avatar asked Dec 08 '10 14:12

sikas


People also ask

What is the proper format to create an ordered list?

To create ordered list in HTML, use the <ol> tag. Ordered list starts with the <ol> tag. The list item starts with the <li> tag and will be marked as numbers, lowercase letters uppercase letters, roman letters, etc.

How do I create a custom ordered list in HTML?

In HTML, we can create an ordered list using the <ol> tag. The ol in the tag stands for an ordered list. Inside each of the ordered list elements <ol> and <ol /> , we have to define the list items. We can define the list items using the <li> tag.

Can you change the style of numbers in an ordered list?

Answer: Type attribute allows us to change the style of numbers in an ordered list. Explanation: The < li > tag includes two attributes – type and value. The type attribute is used to modify the order numbering in the list item.


2 Answers

You can, but only with the more up-to-date browsers (Chrome, Safari, Firefox and Opera will work):

ol {
  counter-reset: listCounter;
}
ol li {
  counter-increment: listCounter;
}
ol li:before {
  content: counter(listCounter) ")";
}
like image 79
David Thomas Avatar answered Oct 13 '22 00:10

David Thomas


You can do this with CSS counter and pseudo elements:

ol li{
    list-style: none;
    counter-increment: myIndex;
}

ol li:before{
    content:counter(myIndex)") ";
}
<ol>
    <li>test</li>
    <li>test</li>
    <li>test</li>
    <li>test</li>
    <li>test</li>
</ol>
like image 43
Klaster_1 Avatar answered Oct 13 '22 00:10

Klaster_1