HtmlAttributes Class

Attached HTML attributes to a MarkdownObject.

public class HtmlAttributes : MarkdownObject
Inheritance
MarkdownObject HtmlAttributes

Constructors

NameDescription
HtmlAttributes()Initializes a new instance of the HtmlAttributes class.

HtmlAttributes()

HtmlAttributes.cs

Initializes a new instance of the HtmlAttributes class.

public HtmlAttributes()

Properties

NameDescription
ClassesGets or sets the CSS classes attached. May be null.
IdGets or sets the HTML id/identifier. May be null.
PropertiesGets or sets the additional properties. May be null.

Gets or sets the CSS classes attached. May be null.

public List<string>? Classes { get; set; }

Property value

List<string>?

Gets or sets the HTML id/identifier. May be null.

public string? Id { get; set; }

Property value

string?

Gets or sets the additional properties. May be null.

public List<KeyValuePair<string, string?>>? Properties { get; set; }

Methods

NameDescription
AddClass(string)Adds a CSS class.
AddProperty(string, string)Adds a property.
AddPropertyIfNotExist(string, object?)Adds the specified property only if it does not already exist.
CopyTo(HtmlAttributes, bool, bool)Copies/merge the values from this instance to the specified HtmlAttributes instance.

AddClass(string)

HtmlAttributes.cs

Adds a CSS class.

public void AddClass(string name)

Parameters

name string
The css class name.

AddProperty(string, string)

HtmlAttributes.cs

Adds a property.

public void AddProperty(string name, string value)

Parameters

name string
The name.
value string
The value.

AddPropertyIfNotExist(string, object?)

HtmlAttributes.cs

Adds the specified property only if it does not already exist.

public void AddPropertyIfNotExist(string name, object? value)

Parameters

name string
The name.
value object?
The value.

CopyTo(HtmlAttributes, bool, bool)

HtmlAttributes.cs

Copies/merge the values from this instance to the specified HtmlAttributes instance.

public void CopyTo(HtmlAttributes htmlAttributes, bool mergeIdAndProperties = false, bool shared = true)

Parameters

htmlAttributes HtmlAttributes
The HTML attributes.
mergeIdAndProperties bool
If set to true it will merge properties to the target htmlAttributes. Default is false
shared bool
If set to true it will try to share Classes and Properties if destination don't have them, otherwise it will make a copy. Default is true

Exceptions

ArgumentNullException