change colors for alternate buttons using CSS with :nth-child(odd) - HTML CSS CSS Form

HTML CSS examples for CSS Form:input button style

Description

change colors for alternate buttons using CSS with :nth-child(odd)

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">

button:nth-child(odd) { background:green }
button:nth-child(even) { background:red }


      </style> 
 </head> <!--from  w  ww  . j  a  v a 2 s . c om-->
 <body> 
  <button></button> 
  <button></button> 
  <button></button> 
  <button></button> 
  <button></button> 
  <button></button>  
 </body>
</html>

Related Tutorials