I have this small problem, I am building a nested ordered list, and I want to be able to customize the styles of top level elements (note that bold is both on the counter and text).
1. AAA
1.1 Lorem ipsum
1.2 Lorem ipsum
1.3 Lorem ipsum
2. BBB
2.1 Lorem ipsum
2.2 Lorem ipsum
2.3 Lorem ipsum
The problem I have encountered is that if I apply any <h>
tag for the top level elements of the list, the counter breaks.
Without the <h3>
tags counters work properly, but without <h3>
I am unable to style top level elements of the list.
How can I get both working counter and styled top level elements?
Sample here:
#test li {
font-size: 16px;
padding: 2px 0;
display: block;
margin-left: 10px
}
#test h3 {
display: inline-block;
padding: 0 0 5px 0;
}
#test ol, ul {
list-style-type: decimal;
}
#test li:before {
content: counters(item, ".") " ";
counter-increment: item
}
#test ol {
counter-reset: item;
margin: 0
}
#test h3>li {
font-size: 26px;
}
<div id="test">
<ol>
<h3><li>AAAA</h3>
<ol>
<li><a href=”#”>Lorem ipsum.</a></li>
<li><a href=”#”>Lorem ipsum.</a></li>
<li><a href=”#”>Lorem ipsum.</a></li>
</ol>
</li>
<h3><li>BBBB</h3>
<ol>
<li><a href=”#”>Lorem ipsum.</a></li>
<li><a href=”#”>Lorem ipsum.</a></li>
<li><a href=”#”>Lorem ipsum.</a></li>
</ol>
</li>
<h3><li>CCCC</h3>
<ol>
<li><a href=”#”>Lorem ipsum.</a></li>
<li><a href=”#”>Lorem ipsum.</a></li>
<li><a href=”#”>Lorem ipsum.</a></li>
</ol>
</li>
</ol>
</div>
`, that's why I used `
` before `