Click here to Skip to main content
14,736,826 members

StringBuilder sb = new StringBuilder();
sb.append("<html>");
sb.append("<head></head>");
sb.append("<body>");
sb.append("<div>My Test Div </div>");
sb.append("</body>");
sb.append("</html>");
   
or you can use Tag Builder. TagBuilder is a class that specially designed for creating html tags and their content.

var tb = new TagBuilder("a");
tb.MergeAttribute("href",link);
tb.AddCssClass(cssClass);
tb.ToString(TagRenderMode.SelfClosing);
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900