2

I would like to define an ordered list with unordered sub-lists. You can see from the example below what I would like to achieve. It works up to the fact that the unordered lists also obtain numbered labels. How can I prevent this (for further sub-lists [so on level 3,4,...] as well)?

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <style type="text/css">
      /* %%% ordered lists, see http://stackoverflow.com/questions/2558358/how-to-add-brackets-a-to-ordered-list-compatible-in-all-browsers# %%% */
      ul {
      list-style-type: square;
      padding: 0em 0em 0em 26px; /* indent from left */
      }

      ul li {
      margin: 0.3em 0em 0em 0em; /* space between elements */
      }

      ol {
      list-style-type: none;
      padding: 0em; /* indent from left */
      }

      ol.orderedlist {
      counter-reset:mycounter;
      list-style-type: none;
      }

      ol.orderedlist li:before {
      content: counter(mycounter) ") ";
      counter-increment:mycounter;
      }
    </style>
  </head>
  <body>
    <ol class="orderedlist">
      <li>Point 1</li>
      <ul>
    <li>Foo</li>
    <li>Bar</li>
      </ul>
      <li>Point 2</li>
      <ul>
    <li>Foo</li>
    <li>Bar</li>
      </ul>
    </ol>
  </body>
</html>
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Marius Hofert
  • 6,546
  • 10
  • 48
  • 102

2 Answers2

4

Use the child selector:

ol.orderedlist > li:before {
content: counter(mycounter) ") ";
counter-increment:mycounter;
}
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
0
ol.orderedlist ul {list-style: square;}

ol ul {list-style: square;}

ol ul ol ul {list-style: square;}
Aaron Brewer
  • 3,567
  • 18
  • 48
  • 78