2

I want to create css to generate the following nested list.

1. item1

  • subitem

  • subitem

2. item2

  • subitem

  • subitem

What I want is to modify the numbers (either bold or red). I searched in the internet but what I found was css for an ordered list. When I create a nested list with that css, what I obtain is extra numbers in place of the bullets. Can someone help?

1 Answer 1

1

You can use CSS counter only on li's that are direct children of ol with this HTML structure and then change color and font-weight.

ol {
  list-style: none;
  counter-reset: ol-counter;   
}
ol > li:before {
  counter-increment: ol-counter;               
  content: counter(ol-counter) ". "; 
  color: red;
  font-weight: bold;
}
<ol>
  <li>item1
    <ul>
      <li>sub item</li>
      <li>sub item</li>
    </ul>
  </li>
  <li>item2
    <ul>
      <li>sub item</li>
      <li>sub item</li>
    </ul>
  </li>
</ol>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.