[ACCEPTED]-Postfix label text with colon-asp.net-mvc

Accepted answer
Score: 38

Through CSS, you can add the colon via the 3 after pseudo class. You can find more information 2 about this pseudo class here.

.editor-label > label:after {
    content: ": "

Working example: http://jsfiddle.net/fJQDZ/

Please note that 1 the after pseudo class is not available in IE7.

Score: 0

For those who want to avoid using pseudo-elements, an 2 alternative is to keep [Display(Name = "Firstname")] and use the @Html.DisplayNameFor() helper 1 with a colon after.

<div><!--                                          **colon below**  ⬇   -->
    <div class="editor-label">@Html.DisplayNameFor(x => x.FirstName):</div>
    <div class="editor-field">@Html.TextBoxFor(x => x.Firstname)</div>

More Related questions