title: How to use if..else condition withing <div> tag in cshtml?
body: <p>I want to use <code>if else</code> condition within <code>&lt;div&gt;</code> tag to display/hide <code>title</code>. What is happening is, sometimes <code>@tag.Description</code> is empty and because of that my HTML shows empty <code>title</code> and I do not want that. </p>
  
  <p><a href="https://i.stack.imgur.com/PNjm3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PNjm3.png" alt="enter image description here"></a></p>
  
  <p>I want to only display <code>title</code> if <code>@tag.Description</code> is not empty otherwise do not show it.</p>
  
  <p>I've added the condition but want to make that it is the right approach.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;ul class="tag-summary"&gt;
      @foreach (var tag in Model.MenuTags)
      {
          &lt;li&gt;
              //Current
              &lt;div class="tag @tag.TagValue" title="@tag.Description"&gt;
                  &lt;label&gt;@tag.Name&lt;/label&gt;
              &lt;/div&gt;
  
              // Code with condition but not sure this is the right way or not
              &lt;div class="tag @tag.TagValue" title="(string.IsNullOrEmpty(@tag.Description) ? null : @tag.Description)"&gt;
                  &lt;label&gt;@tag.Name&lt;/label&gt;
              &lt;/div&gt;
  
              &lt;div class="tag-definition"&gt;@tag.Description&lt;/div&gt;
          &lt;/li&gt;
      }
  &lt;/ul&gt;
  </code></pre>