I do not know why there is no default support for htmAttributes in the HtmlHelper.LabelFor method. Without the ability to supply inline attributes, we would need to use CSS and target the elementId. That is not the best option, especially when we have one-off scenarios and need to apply styling to only a single label, or any html element. In my opinion, inline CSS is cleaner because it keeps the style and the element declaration together.

Here is a my quick implementation to support htmlAttributes as an extension method.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Web;
   5:   
   6:  namespace Engroove.Consulting.Helpers
   7:  {
   8:      using System.Linq.Expressions;
   9:      using System.Web.Mvc;
  10:      using System.Web.Mvc.Html;
  11:      using System.Web.Routing;
  12:   
  13:      /// <summary>
  14:      /// Adds htmlAttributes to the label helper.
  15:      /// </summary>
  16:      public static class LabelHelper
  17:      {
  18:          public static MvcHtmlString LabelFor<TModel, TProperty>(this HtmlHelper<TModel> helper,
  19:             Expression<Func<TModel, TProperty>> expression,
  20:             object htmlAttributes)
  21:          {
  22:              IDictionary<string, string> attribHash = htmlAttributes as IDictionary<string, string>;
  23:              if (attribHash == null)
  24:                  return helper.LabelFor(expression);
  25:   
  26:              string displayName =  ModelMetadata.FromLambdaExpression(
  27:                  expression, helper.ViewData).DisplayName;
  28:   
  29:              string attributes = string.Empty;
  30:              foreach (var kp in attribHash)
  31:              {
  32:                  attributes += string.Format(" {0}=\"{1}\"", kp.Key, kp.Value);
  33:              }
  34:   
  35:              return MvcHtmlString.Create(
  36:                  string.Format("<label for=\"{0}\" {1}>{0}</label>", displayName, attributes.Trim()));
  37:          }
  38:      }
  39:  }

And use it like this:


<%: Html.LabelFor(m => m.FirstName, 
                    new Dictionary<string, string>() { {"style", "font-weight: bold; display: inline;"} }) %>