You can see it here: codepen
Short answer: That's the normal behavior. List-style numbers don't inherit their styles from list headings. they have their own styles and you can't select and style them directly. you can just remove list-style (by list-style:none
) and create your own list-style numbers with css, and apply styles to them. (Described in long answer)
Long answer:
- apply
display: inline;
to your headings:
ol > li > h1{
display: inline;
}
- add custom stylable list style numbers:
ol {
list-style: none;
counter-reset: counter;
}
ol > li {
counter-increment: counter;
}
ol > li::before {
content: counter(counter) ". ";
display: inline;
}
- apply same style as h1 default style to the list style : (you can see h1 deafult styles here : html default styles)
ol > li::before {
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
Full style:
ol {
list-style: none;
counter-reset: counter;
}
ol > li {
counter-increment: counter;
}
ol > li > h1{
display: inline;
}
ol > li::before {
content: counter(counter) ". ";
display: inline;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}