In order to output your HTML without rewriting it each time, you will need to use one of the following:
- An actual programming language (Such as PHP)
- A framework/library (such as React)
- A preprocessor/templating system (such as Haml or Pug)
Using PHP is simple enough, if you have PHP installed on your webhost (you almost certainly do).
For instance, instead of this:
index.html:
<div class="design design-0">Design</div>
<div class="design design-1">Design</div>
<div class="design design-2">Design</div>
<div class="design design-3">Design</div>
You could have this:
index.php
<?php for( $i = 0; $i < 4; $i++ ){
echo "<div class='design design-$i'>Design</div>";
} ?>
Or check out this Pug example: https://codepen.io/xhynk/pen/OJPvPMX if you would rather use a preprocessor.
For the CSS though, as @Calvin Nunes said, you can make use of the :nth-of-type() selector or even the Adjacent Sibling Combinator - though these largely make the need for the design-x type classes unnecessary, unless you have other reasons to include them.
designXclasses is unique you should use anidinstead.id="design1"— IDs are meant to be unique, while the whole point of class is that many things can be of the same class. Also, it might make sense to use both:<div class="design" id="d1">...</div>