BaseTag<T> Interface

Represents basic features of an HTML element.

C#
public interface BaseTag<out T>
where T : BaseTag<T>

Type Parameters

T
BaseTag<T>

The type of an HTML element.

Properties

Name

Gets the name of this tag in lowercase letters.

Methods

WithId(string)

Gets a new BaseTag<T> object with the id attribute that has the specified value.

WithClass(string[])

Gets a new BaseTag<T> object with the class attribute that has the specified values.

AddClass(string[])

Gets a new BaseTag<T> object with the class attribute that has both the values of this object and the specified values.

AddAttributes((string Name, string Value)[])

Gets a new BaseTag<T> object with the specified attribute that has the specified value.

AddEmptyAttributes(string[])

Gets a new BaseTag<T> object with the specified empty attribute.

Properties Detail

Name

Gets the name of this tag in lowercase letters.

C#
string Name { get; }

Property Value

Methods Detail

WithId(string)

Gets a new BaseTag<T> object with the id attribute that has the specified value.

C#
T WithId(string id)

Parameters

id
string

The value of the id attribute.

Returns

T

The new BaseTag<T> object.

WithClass(string[])

Gets a new BaseTag<T> object with the class attribute that has the specified values.

C#
T WithClass(params string[] values)

Parameters

values
string[]

The values of the class attribute.

Returns

T

The new BaseTag<T> object.

AddClass(string[])

Gets a new BaseTag<T> object with the class attribute that has both the values of this object and the specified values.

C#
T AddClass(params string[] values)

Parameters

values
string[]

The adding values of the class attribute.

Returns

T

The new BaseTag<T> object.

AddAttributes((string Name, string Value)[])

Gets a new BaseTag<T> object with the specified attribute that has the specified value.

C#
T AddAttributes(params (string Name, string Value)[] attributes)

Parameters

attributes
(string Name, string Value)[]

Tuples of the name and value representing an attribute. If the value of the tuple is null, it represents the empty attribute.

Returns

T

The new BaseTag<T> object.

AddEmptyAttributes(string[])

Gets a new BaseTag<T> object with the specified empty attribute.

C#
T AddEmptyAttributes(params string[] attributeNames)

Parameters

attributeNames
string[]

The name of the empty attribute.

Returns

T

The new BaseTag<T> object.

Remarks

An invocation of this method of the form tag.AddEmptyAttributes(n1, n2) behaves in exactly the same way as the invocation tag.AddAttributes((n1, null), (n2, null)).

The web browser interprets the value of the empty attribute as the empty string implicitly. So, for example, <input disabled> is equivalent to <input disabled="">. The former can be generated with AddEmptyAttributes("disabled") or AddAttributes(("disabled", null)), and the latter with AddAttributes(("disabled", "")).