title: Thymeleaf: how to use conditionals to dynamically add/remove a CSS class
body: <p>By using <a href="https://www.google.it/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0CCMQFjAA&amp;url=http%3A%2F%2Fwww.thymeleaf.org%2F&amp;ei=MI7gU6nJDcqp0QWQ5IDACA&amp;usg=AFQjCNEO8zpPJdx9vZOpb_nC-Zdd8gu03Q&amp;sig2=YpHXOZrgN-CgTai_imJrUA&amp;bvm=bv.72197243,d.bGE" rel="noreferrer"><strong>Thymeleaf</strong></a> as template engine, is it possible to add/remove dynamically a CSS class to/from a simple <code>div</code> with the <code>th:if</code> clause?</p>
  
  <p>Normally, I could use the conditional clause as follows:</p>
  
  <pre><code>&lt;a href="lorem-ipsum.html" th:if="${condition}"&gt;Lorem Ipsum&lt;/a&gt; 
  </code></pre>
  
  <blockquote>
    <p>We will be creating a link to the <em>lorem ipsum</em> page, but only if condition clause is true.</p>
  </blockquote>
  
  <p>I'm looking for something different: I'd like the block to always visible, but with changeable classes according to the situation.</p>