w3resource
HTML exercises

HTML CSS Exercise: Set count and insert it before elements

Solution:

HTML Code :

<!doctype html>
<html>
<head>
<title>HTML CSS Exercise - Set count and insert it before elements</title>
<style>
ol {
  counter-reset: Step;                /* Creates a new instance of the
                                        Step counter with each ol
                                            element */
  list-style-type: none;
}
li:before {
  counter-increment: Step;            /* Increments only this instance
                                            of the Step counter */
  content: counters(Step,".") " ";    /* Adds the value of all instances
                                            of the Step counter separated
                                            by a ".". */
                                         
}
</style>
</head>
<body>
<ol>
  <li>item</li>          <!-- 1     -->
  <li>item               <!-- 2     -->
    <ol>
      <li>item</li>      <!-- 2.1   -->
      <li>item</li>      <!-- 2.2   -->
      <li>item           <!-- 2.3   -->
        <ol>
          <li>item</li>  <!-- 2.3.1 -->
          <li>item</li>  <!-- 2.3.2 -->
        </ol>
        <ol>
          <li>item</li>  <!-- 2.3.1 -->
          <li>item</li>  <!-- 2.3.2 -->
          <li>item</li>  <!-- 2.3.3 -->
        </ol>
      </li>
      <li>item</li>      <!-- 2.4   -->
    </ol>
  </li>
  <li>item</li>          <!-- 3     -->
  <li>item</li>          <!-- 4     -->
</ol>
<ol>
  <li>item</li>          <!-- 1     -->
  <li>item</li>          <!-- 2     -->
</ol></body>
</html>

Live Demo:

See the Pen set-counter-and-insert-before-answer by w3resource (@w3resource) on CodePen.


Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
YesYesYesYesYes

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming


bedava porno