title: How to add a class to html element dynamically using razor syntax?
body: <p>I want to add class to a <code>&lt;tr&gt;</code> element depending on model's attribute:</p>
  
  <pre><code>&lt;table&gt;
    &lt;tbody&gt;
     @foreach (var item in Model)
     {
       if (item.Level == 1)
       {
         &lt;tr class="classA"&gt;
       }
       else if (item.Level == 2)
       {
         &lt;tr class="classB"&gt;
       }
       else
       {
         &lt;tr&gt;
       }
  
       &lt;td&gt;...&lt;/td&gt;
       &lt;td&gt;...&lt;/td&gt;         
  
       &lt;/tr&gt;
     &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>My IDE tells me my <code>&lt;tr&gt;</code> element is not closed. How can I dynamically add the class value using razor?</p>