Class
HtmlElement
Represents an HTML element for rendering
public class HtmlElement : INodeInheritance #
Implements #
Inherited Members #
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Extension Methods #
XmlNodeExtensions.SelfClosed<HtmlElement>(HtmlElement), XmlNodeExtensions.WithAttribute<HtmlElement>(HtmlElement, string), XmlNodeExtensions.WithAttribute<HtmlElement>(HtmlElement, string, object?), XmlNodeExtensions.WithAttributes<HtmlElement>(HtmlElement, object?), HtmlElementExtensions.WithClass<HtmlElement>(HtmlElement, params string[]), XmlNodeExtensions.WithContent<HtmlElement>(HtmlElement, Action<HtmlElement>), XmlNodeExtensions.WithContent<HtmlElement>(HtmlElement, object?), XmlNodeExtensions.WithContent<HtmlElement>(HtmlElement, string?), HtmlElementExtensions.WithId<HtmlElement>(HtmlElement, string), HtmlElementExtensions.WithName<HtmlElement>(HtmlElement, string), HtmlElementExtensions.WithStyle<HtmlElement>(HtmlElement, object)
Constructors #
| Name | Description |
|---|---|
| HtmlElement() | Initializes a new instance of the HtmlElement class with no container HTML element. |
| HtmlElement(string) | Initializes a new instance of the HtmlElement class with the specified tag name. |
| HtmlElement(string, object?) | Initializes a new instance of the HtmlElement class with the specified tag name and content. |
| HtmlElement(string, string?) | Initializes a new instance of the HtmlElement class with the specified tag name and content. |
| HtmlElement(string, Action<HtmlElement>) | Initializes a new instance of the HtmlElement class with the specified tag name. |
Properties #
| Name | Description |
|---|---|
| Attributes | Gets or sets the collection of HTML attributes for the element. |
| Children | Gets or sets the collection of child elements within this element. |
| ClassList | Gets or sets the list of CSS classes for the HTML element. Initializes with an empty list. Use this to apply CSS class names to the element. |
| Id | Gets or sets the ID attribute of the HTML element. Used to uniquely identify the element within the page. |
| Name | Gets or sets the name attribute of the HTML element. The name is used to reference elements in JavaScript, or to reference form data after a form is submitted. |
| SelfClosing | Gets or sets a value indicating whether the element is self-closing. |
| Style | Gets or sets the CSS style object used to render the style attribute. |
| TabIndex | Gets or sets the tab index of the HTML element. |
| TagName | Gets or sets the tag name of the HTML element (e.g., “div”, “span”). |
| TooltipTitle | Gets or sets the tooltip text to display for the HTML element. |
Methods #
| Name | Description |
|---|---|
| Create(string) | Creates an HtmlElement from the specified emmet template. |
| Create(string, object?, object?, object?[]?, bool) | Creates an HtmlElement from the specified emmet template and adds the specified style, attributes, and children. |
| Create(string, Action<HtmlElement>) | Creates an HtmlElement from the specified emmet template and configures it using the specified action. |
| Format(FormattableString) | Formats the specified HTML string format, escaping the string interpolation pieces. |
| Fragment(params object?[]) | Creates an fragment HtmlElement with specified children. |
| Fragment(Action<HtmlElement>) | Creates an fragment HtmlElement with specified self-action. |
| GetAttributes() | Represents the protected method which gets the attributes to be rendered. |
| ToString() | Renders the HTML element into a string with optional pretty formatting. |
Operators #
| Name | Description |
|---|---|
| operator +(HtmlElement, object?) |