title: Conditional HTML Attributes using Razor MVC3
body: <p>The variable strCSSClass often has a value but sometimes is empty. </p>
  
  <p>I do not want to include an empty class="" in this input element's HTML, which means if strCSSClass is empty, I don't want the class= attribute at all.</p>
  
  <p>The following is one way to do a conditional HTML attribute:</p>
  
  <pre><code>&lt;input type="text" id="@strElementID" @(CSSClass.IsEmpty() ? "" : "class=" + strCSSClass) /&gt;
  </code></pre>
  
  <p>Is there a more elegant way of doing this? Specifically one where I could follow the same syntax as is used in the other parts of the element: class="@strCSSClass" ?</p>