Provides constant definitions for identifiers used in HTML including tags and attributes.
This package provides the string values for various HTML identifiers.
The HtmlTags
static class provides constant values for HTML tag names.
var tag = $"<{HtmlTags.Div}>";
Console.WriteLine(tag); // output: <div>
The HtmlAttributes
static class provides access to individual MarkupAttribute
objects.
var idAttribute = $"{HtmlAttributes.Id()}='1234'";
Console.WriteLine(idAttribute); // output: id="1234"
Optionally a value can be provided to the attribute. The value will be escaped as needed.
var idAttribute = HtmlAttributes.Id("1234")";
Console.WriteLine(idAttribute); // output: id="1234"
Attributes that are known to be valid for various HTML tags also made available though static read only "For" prefixed members.
var attribute = HtmlAttributes.ForImg.Alt("dog")";
Console.WriteLine(attribute); // output: alt="dog"
Predefined HTML attribute values can be accessed via the HtmlAttributeValues
static class.
var attribute = $"method='{HtmlAttributeValues.Post}'";
Console.WriteLine(attribute); // output: method='post'
"For" static members also are made available on the HtmlAttributeValues
class. These members provide known predefined values for a specific attribute.
var attribute = $"method='{HtmlAttributeValues.ForMethod.Post}";
Console.WriteLine(attribute); // output: method='post'