I am incorporating TagHelpers
in my MVC vNext project, and I realized they don't work when I self close the HTML tags.
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
<label asp-for="FirstName"/> <!-- self closing tag -->
<span asp-validation-for="FirstName"/> <!-- self closing tag -->
And, insteand when I put the closing tags, I see the values being displayed.
<label asp-for="FirstName"></label>
<span asp-validation-for="FirstName"></span>
Generated HTML
<label for="FirstName">FirstName</label>
<span class="field-validation-error" data-valmsg-for="FirstName" data-valmsg-replace="true">
<span id="FirstName-error" class="">The FirstName field is required</span>
</span>
What I want to know, what difference does it make? And, is self closing the paired tags a bad habit. If you know some article which talks about this design principle, please share with me, it would be much appreciated.
non-void elements
: #3558619 – Labroiddiv
,span
,textarea
, etc. Those tags requires to have end tag. – Labroid