/// <summary> /// Original code that is generating the label /// </summary> protected void GenerateLabelHtml(TextWriter writer, string hiddenSpan = "", string customLabel = "") { var tagBuilder = HtmlGenerator.GenerateLabel( ViewContext, For.ModelExplorer, For.Name, string.IsNullOrEmpty(customLabel) ? null : customLabel, new { @class = "govuk-label" }); if (!string.IsNullOrWhiteSpace(hiddenSpan) && hiddenSpan.Length > 1) { tagBuilder.InnerHtml.AppendHtml($"<span class=\"govuk-visually-hidden\">{hiddenSpan}</span>"); } tagBuilder.WriteTo(writer, HtmlEncoder); }