Answers.Body: <p>You can <code>cycle</code> your <code>loop.index0</code> property if you really need to add a class </p>
  
  <pre><code>{{ cycle(['first', 'second', 'last'], loop.index0) }}
  </code></pre>
  
  <p>If the other elements don't need a class insert an empty value <code>''</code></p>
  
  <p>You can as well check for a specific value of your <code>loop.index0</code></p>
  
  <p>However if you just want to add certain style attributes you can use the <a href="https://css-tricks.com/how-nth-child-works/" rel="nofollow noreferrer">nth</a> selector </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-06T10:58:30.923Z
Answers.Text: THAT worked like a charm!
  THANKS!
Answers.UserDisplayName: PLAN42
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-06T10:37:20.807Z
Answers.LastActivityDate: 2018-05-06T10:37:20.807Z
Answers.UserDisplayName: Robin Schambach
Body: <p>Trying to add entries in a visual array on my homepage.
  Problem is that I need a special class on the last item in every row.<br>
  <em>col_last</em></p>
  
  <p>Trying to get my head around how to automate this, in order to avoid "special entries" for these. </p>
  
  <p>Any ideas?</p>
  
  <pre><code>{% for item in craft.entries.section('services').orderBy('postDate asc').all() %}
      &lt;div class="clear bottommargin-sm"&gt;&lt;/div&gt;
      &lt;div class="col_one_third *col_last*"&gt;
          &lt;div class="feature-box fbox-small fbox-plain" data-animate="fadeIn"&gt;
              &lt;div class="fbox-icon"&gt;
                  &lt;a href="#"&gt;&lt;i class="icon-{{ item.serviceIcon }}"&gt;&lt;/i&gt;&lt;/a&gt;
              &lt;/div&gt;
              &lt;h3&gt;{{ item.title }}&lt;/h3&gt;
              &lt;p&gt;{{ item.serviceTagline }}&lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  {% endfor %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-06T10:28:26.690Z
Comments.Text: Do you really need a special class or just a special style (css)?
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-06T10:37:11.337Z
Comments.Text: Unfortunately I need to ADD a class, but I guess it pretty much the same procedure to single out every 3'rd item.
Comments.UserDisplayName: PLAN42
Tags: <templating>
Title: Add style on every third entry
ThreadText: # Add style on every third entry
  
  (Asked by: username_0 on 2018-05-06)
  
  Trying to add entries in a visual array on my homepage.
  Problem is that I need a special class on the last item in every row.  
  *col\_last*
  
  Trying to get my head around how to automate this, in order to avoid "special entries" for these.
  
  Any ideas?
  
  ```
  {% for item in craft.entries.section('services').orderBy('postDate asc').all() %}
      <div class="clear bottommargin-sm"></div>
      <div class="col_one_third *col_last*">
          <div class="feature-box fbox-small fbox-plain" data-animate="fadeIn">
              <div class="fbox-icon">
                  <a href="#"><i class="icon-{{ item.serviceIcon }}"></i></a>
              </div>
              <h3>{{ item.title }}</h3>
              <p>{{ item.serviceTagline }}</p>
          </div>
      </div>
  {% endfor %}
  
  ```
  
  **Tags:** templating
  
  > **Comments:**
  > **username_1**: Do you really need a special class or just a special style (css)?  
  > **username_0**: Unfortunately I need to ADD a class, but I guess it pretty much the same procedure to single out every 3'rd item.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-05-06. Score: 4 | Accepted answer
  
  You can `cycle` your `loop.index0` property if you really need to add a class
  
  ```
  {{ cycle(['first', 'second', 'last'], loop.index0) }}
  
  ```
  
  If the other elements don't need a class insert an empty value `''`
  
  You can as well check for a specific value of your `loop.index0`
  
  However if you just want to add certain style attributes you can use the [nth](https://css-tricks.com/how-nth-child-works/) selector
  
  > **Comments:**
  > **username_0**: THAT worked like a charm! THANKS!  
  
  ---
  
  