4

Is it possible to add a class to a br tag when using the HtmlTextWriter.WriteBreak method?

writer.AddAttribute(HtmlTextWriterAttribute.Class, "className");
writer.WriteBreak();

I need an xHtml compliant html output and therefore the WriteBreak is perfect as it writes

<br />

I want to add a class to the br so that I have

<br class="className" />
skyfoot
  • 20,629
  • 8
  • 49
  • 71

1 Answers1

5

You can do it manually, like this:

writer.WriteBeginTag("br");
writer.WriteAttribute("class", "className");
writer.Write(HtmlTextWriter.SelfClosingTagEnd);
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964