Set <ol> list-style background color - HTML CSS CSS Property

HTML CSS examples for CSS Property:background-color

Description

Set <ol> list-style background color

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

ol li
{
   counter-increment: step-counter;<!--from  w  w  w  .jav  a 2  s .  c o  m-->
}
ol li::before
{
   content: counter(step-counter);
}
ol li:nth-of-type(1)::before
{
   background-color: yellow;
}
ol li:nth-of-type(2)::before
{
   background-color: red;
}
ol li:nth-of-type(3)::before
{
   background-color: orange;
}
ol li:nth-of-type(4)::before
{
   background-color: green;
}
ol li:nth-of-type(5)::before
{
   background-color: aqua;
}
ol
{
   list-style-type: none;
}


      </style> 
 </head> 
 <body> 
  <ol> 
   <li> ..text.. </li> 
   <li> ..text.. </li> 
   <li> ..text.. </li> 
   <li> ..text.. </li> 
   <li> ..text.. </li> 
  </ol>  
 </body>
</html>

Related Tutorials