HtmlForgeX

API Reference

Class

HtmlTag

Namespace HtmlForgeX
Assembly HtmlForgeX
Base Element

Represents a generic HTML tag that can contain attributes and child elements. This is the fundamental building block used when manually composing DOM structures with HtmlForgeX.

Inheritance

Constructors

HtmlTag 5 overloads
public HtmlTag(String tag) #

Initializes a new instance of the HtmlTag class with the specified tag name.

Parameters

tag System.String requiredposition: 0
The name of the tag.
public HtmlTag(String tag, TagMode tagMode) #

Initializes a new instance of the HtmlTag class with a value contained within the tag.

Parameters

tag System.String requiredposition: 0
The name of the tag.
value System.String requiredposition: 1
The inner value for the tag.
HtmlTag(System.String tag, HtmlForgeX.TagMode tagMode) #

Initializes a new instance of the HtmlTag class with the specified tag mode.

Parameters

tag System.String required
The name of the tag.
tagMode HtmlForgeX.TagMode required
The TagMode indicating how the tag should be rendered.
public HtmlTag(String tag, String value, TagMode tagMode) #

Initializes a new instance of the HtmlTag class with a value and specific tag mode.

Parameters

tag System.String requiredposition: 0
The name of the tag.
value System.String requiredposition: 1
The inner value for the tag.
tagMode HtmlForgeX.TagMode requiredposition: 2
The TagMode indicating how the tag should be rendered.
public HtmlTag(String tag, String value, Dictionary<String, Object> attributes = null, TagMode tagMode = Normal) #

Initializes a new instance of the HtmlTag class with a value, attributes and tag mode.

Parameters

tag System.String requiredposition: 0
The name of the tag.
value System.String requiredposition: 1
The inner value for the tag.
attributes System.Collections.Generic.Dictionary{System.String,System.Object} = null optionalposition: 2
Optional attributes to apply.
tagMode HtmlForgeX.TagMode = Normal optionalposition: 3
The TagMode indicating how the tag should be rendered.

Methods

public override Element Add(Element element) #
Returns: Element

Adds an element as a child of this HtmlTag.

Parameters

element HtmlForgeX.Element requiredposition: 0
The element to add.

Returns

This element for method chaining.

public HtmlTag AddChild(Element element) #
Returns: HtmlTag

Adds the specified element as a child of this tag.

Parameters

element HtmlForgeX.Element requiredposition: 0
Element to add.

Returns

The current HtmlTag instance.

public HtmlTag AddText(String text) #
Returns: HtmlTag

Adds a text node to this tag.

Parameters

text System.String requiredposition: 0
The text to add.

Returns

The current HtmlTag instance.

public HtmlTag Attribute(String name, String value) #
Returns: HtmlTag

Adds or updates an attribute on the tag.

Parameters

name System.String requiredposition: 0
The attribute name.
value System.String requiredposition: 1
The attribute value.

Returns

The current HtmlTag instance.

public HtmlTag Class(String className) #
Returns: HtmlTag

Adds a CSS class to the tag.

Parameters

className System.String requiredposition: 0
The class name to add.

Returns

The current HtmlTag instance.

public HtmlTag Id(String id) #
Returns: HtmlTag

Sets the id attribute for the tag.

Parameters

id System.String requiredposition: 0
The id value.

Returns

The current HtmlTag instance.

public HtmlTag Style(String name, String value) #
Returns: HtmlTag

Adds a style declaration to the tag.

Parameters

name System.String requiredposition: 0
The CSS property name.
value System.String requiredposition: 1
The CSS property value.

Returns

The current HtmlTag instance.

public override String ToString() #
Returns: String

Returns the HTML representation of the tag.

Returns

A string containing the rendered HTML.

public HtmlTag Type(String type) #
Returns: HtmlTag

Sets the type attribute for the tag.

Parameters

type System.String requiredposition: 0
The type value.

Returns

The current HtmlTag instance.

Value 5 overloads
public HtmlTag Value(Element value) #
Returns: HtmlTag

Appends a child tag.

Parameters

child HtmlForgeX.HtmlTag requiredposition: 0
The child tag to add.

Returns

The current HtmlTag instance.

Value(HtmlForgeX.Element value) #

Appends a child element.

Parameters

value HtmlForgeX.Element required
The child element.

Returns

The current HtmlTag instance.

public HtmlTag Value(String value) #
Returns: HtmlTag

Appends a string value to the tag.

Parameters

value System.String requiredposition: 0
The text value.

Returns

The current HtmlTag instance.

public HtmlTag Value(params String[] value) #
Returns: HtmlTag

Appends multiple string values to the tag.

Parameters

value System.String[] requiredposition: 0
String values to append.

Returns

The current HtmlTag instance.

public HtmlTag Value(params Object[] value) #
Returns: HtmlTag

Appends multiple objects to the tag using their ToString representation.

Parameters

value System.Object[] requiredposition: 0
Objects to append.

Returns

The current HtmlTag instance.

public HtmlTag ValueRaw(String value, Boolean sanitize = false) #
Returns: HtmlTag

Appends raw HTML content to the tag with optional sanitization.

Parameters

value System.String requiredposition: 0
Raw HTML string.
sanitize System.Boolean = false optionalposition: 1
Whether to sanitize the HTML.

Returns

The current HtmlTag instance.

public HtmlTag ValueText(String value) #
Returns: HtmlTag

Appends an HTML-encoded text node to the tag. Prefer this over String) for dynamic/untrusted content.

Parameters

value System.String requiredposition: 0

Properties

public Dictionary<String, Object> Attributes { get; set; } #

Gets the collection of attributes applied to this tag.

Extension Methods

public static HtmlTag Height(HtmlTag tag, TablerHeight height) #
Returns: HtmlTag

Set element height using inline styles

Parameters

tag HtmlForgeX.HtmlTag requiredposition: 0
height HtmlForgeX.TablerHeight requiredposition: 1
public static HtmlTag MaxHeight(HtmlTag tag, TablerHeight height) #
Returns: HtmlTag

Set element max height using inline styles

Parameters

tag HtmlForgeX.HtmlTag requiredposition: 0
height HtmlForgeX.TablerHeight requiredposition: 1
public static HtmlTag MaxWidth(HtmlTag tag, TablerWidth width) #
Returns: HtmlTag

Set element max width using inline styles

Parameters

tag HtmlForgeX.HtmlTag requiredposition: 0
width HtmlForgeX.TablerWidth requiredposition: 1
public static HtmlTag MinHeight(HtmlTag tag, TablerHeight height) #
Returns: HtmlTag

Set element min height using inline styles

Parameters

tag HtmlForgeX.HtmlTag requiredposition: 0
height HtmlForgeX.TablerHeight requiredposition: 1
public static HtmlTag MinWidth(HtmlTag tag, TablerWidth width) #
Returns: HtmlTag

Set element min width using inline styles

Parameters

tag HtmlForgeX.HtmlTag requiredposition: 0
width HtmlForgeX.TablerWidth requiredposition: 1
public static HtmlTag Width(HtmlTag tag, TablerWidth width) #
Returns: HtmlTag

Set element width using inline styles

Parameters

tag HtmlForgeX.HtmlTag requiredposition: 0
width HtmlForgeX.TablerWidth requiredposition: 1