Apply a style for 4 blogs and another style for the next 4 blogs in wordpress blog page?

In the following code you could add a class specifically based on the position in the loop:

<?php
    /* Start the Loop */
    $i = 1;
    $class="first-class";
    while ( have_posts() ) : the_post();

        if($i % 4 == 0){
            $class="second-class-".+$i;
        }

        echo '<div class="'.$class.'">'

        get_template_part( 'template-parts/content', get_post_format() );

        echo '</div>'
        $i++;

    endwhile;

?>

This is essentially a wrapper – it does not have to be a div, it could be a span – but it will count through the loop and change the wrapper class based on if the count in the loop is greater than 3 (first 4 posts 0-3). You then base your CSS off the wrapper class for greater specificity.

tech