I want this:
1. Main
1.1 sub1
1.2 sub2
2. Main2
2.1 sub3
is it possible to do this in HTML? Thanks.
This solution works for me:
/* hide original list counter */
ol li {display:block;}
/* OR */
ol {list-style:none;}
ol > li:first-child {counter-reset: item;} /* reset counter */
ol > li {counter-increment: item;} /* increment counter */
ol > li:before {content:counters(item, ".") ". "; font-weight:bold;} /* print counter */
Yes, at least in a modern browser:
li li:before {
counter-increment: item;
content: counter(item) ". ";
}
(The li li
is so it only does this after the first level.)
You'll probably need counter-reset
as well.
body
{
counter-reset:section;
}
h1
{
counter-reset:subsection;
}
h1:before
{
counter-increment:section;
content:"Section " counter(section) ". ";
}
h2:before
{
counter-increment:subsection;
content:counter(section) "." counter(subsection) " ";
}
body
{
counter-reset:section;
}
This is the sample of counter-increment and counter-reset.