Skip to content

kyleherzog/WebIdentifiers.Html

Repository files navigation

WebIdentifiers.Html

Provides constant definitions for identifiers used in HTML including tags and attributes.

Nuget

Build Status

Overview

This package provides the string values for various HTML identifiers.

HtmlTags

The HtmlTags static class provides constant values for HTML tag names.

var tag = $"<{HtmlTags.Div}>";
Console.WriteLine(tag); // output: <div>

HtmlAttributes

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"

HtmlAttributeValues

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'

About

A .NET package providing access to HTML constant identifiers including tags and attributes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages