There is a simple way of doing this - use \n
instead of <br />
, and use CSS to make it work.
Model:
[DisplayName("Gross Gallons\n(Max: 6,000)")]
public decimal GrossGallons { get; set; }
CSS:
label { white-space: pre-wrap; }
I would recommend making the CSS selector as specific as possible, so as not to catch other labels (in case you're using labels by hand elsewhere, where your source code may contain whitespace). For example, in bootstrap I would've applied this to label.control-label
.
You could also attach a more specific style to that label only, and style only that class.
@Html.LabelFor(m => m.GrossGallons, new { @class = "multiline-label" })