An HTML builder library to create html using a fluent C# builder pattern with no external package dependencies. See below for some code examples.
var builder = new HTMLBuilder();
builder.Document().Body(content: "Hello world!");
System.Diagnostics.Debug.WriteLine(builder.ToString());
<!DOCTYPE html>
<html>
<body>Hello world!</body>
</html>
var builder = new HTMLBuilder();
builder.Document("en").Body()
.Comment("A comment for" + Environment.NewLine + "a div element")
.Div(content: "HTML comments test");
System.Diagnostics.Debug.WriteLine(builder.ToString());
<!DOCTYPE html>
<html lang="en">
<body>
<!--
A comment for
a div element
-->
<div>HTML comments test</div>
</body>
</html>
var builder = new HTMLBuilder();
builder.Document().Body()
.H(1, "Component example")
.BeginComponent("My Component")
.Div("Main component element")
.Child()
.AddElement("span", "Extra component content")
.Parent()
.EndComponent();
System.Diagnostics.Debug.WriteLine(builder.ToString());
<!DOCTYPE html>
<html>
<body>
<h1>Component example</h1>
<!-- Begin My Component -->
<div class="Main component element">
<span>Extra component content</span>
</div>
<!-- End My Component -->
</body>
</html>