MVC Razor, add if statement to foreach loop

MVC should detect html tags and render those out, however it seem this doesnt always work.

In between the curly brackets, try adding a tag

eg:

{
<text> 
   your html 
</text>
} 

or

if you just adding the class try something like:

<tr @(item.status == "Active" ? String.Empty : "class=\"danger\"" )>

try below code.

@{
    var counter = 0;            
}
@foreach (var item in Model)
{
       if(item.status == "Active") {
          <text> <tr> </text>
       }
       else {
           <text><tr class="danger"></text>
       }
       <td>@counter</td>
       <td>@item.FirstName @item.LastName</td>
       <td>@item.Email</td>
       <td>@item.PhoneNumber</td>
       <td>Ändra</td>
       <td>Inaktivera</td>
        </tr>     
    counter++;
}