Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add brackets (a) to ordered list? compatible in all browsers

Tags:

I have to show like

(a)

(b)

(c)

Update:

I found a CSS way

ol {list-style-type: none;}
li:before {content: "(" counter(section, lower-alpha) ") ";}
li { counter-increment: section;}

but it not works in IE 7 and lower.

like image 513
Jitendra Vyas Avatar asked Apr 01 '10 05:04

Jitendra Vyas


People also ask

How do you add brackets in html?

To open the body of an HTML first open the HTML document, to do so write an open bracket, then html, the close the bracket. Next press enter. Type another open bracket, then type the word body, then type a closed bracket.

How do you add a bracket in CSS?

Go to your CSS page and write the name of the section. For example: body, p, head, div class, etc. Put curly brackets: { } Inside of the curly brackets, state what you would like to change.


2 Answers

This is possible with custom counters, but at least IE7- doesn't support it, some others mightn't either. See here for details: http://www.quirksmode.org/css/counter.html

Ex:

li:before {
    content: "(" counter(mycounter,lower-latin) ")";
}
like image 178
deceze Avatar answered Oct 04 '22 16:10

deceze


I use this code snippet in mediawiki with CSS enabled. I am not sure whether this will work in older versions of IE...

<style>
    /* css handles the parentheses/brackets */
    .laparent ol { counter-reset: item }
    .laparent li { display: block ; counter-increment: item; }
    /* replace the counter before list item with
              open parenthesis + counter + close parenthesis */
    .laparent li:before { content: " (" counter(item,lower-alpha) ") "; }
</style>
<ol class="laparent">
    <li> this is the first item; </li>
    <li> this is the second item; or </li>
    <li> this is the third item. </li>
</ol>

Outputs:

(a) this is the first item;
(b) this is the second item; or
(c) this is the third item. 
like image 44
Allan Avatar answered Oct 04 '22 18:10

Allan