CssStyleDeclaration Class

https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface

Implements

Properties

NameDescription
CountGets the number of declarations in the block.
CssTextGets or sets the serialization of the declaration block. Setting the value replaces all the declarations.
LengthGets the number of declarations in the block.
ParentRuleGets the rule that contains the declaration block, or null when the block is not in a rule.

Gets the number of declarations in the block.

public int Count { get; }

Property value

int

Gets or sets the serialization of the declaration block. Setting the value replaces all the declarations.

public string CssText { get; set; }

Gets the number of declarations in the block.

public uint Length { get; }

Gets the rule that contains the declaration block, or null when the block is not in a rule.

public CssRule? ParentRule { get; }

Indexers

NameDescription
this[int]Gets the name of the property at the given index.
this[uint]Gets the name of the property at the given index, or an empty string when the index is out of range.

ItemAt overloads

Gets the name of the property at the given index.

public string this[int index] { get; }
Parameters
index int
Property value

string

Gets the name of the property at the given index, or an empty string when the index is out of range.

public string this[uint index] { get; }

Methods

NameDescription
GetEnumerator()Returns an enumerator over the names of the properties of the block.
GetPropertyPriority(string)Returns the priority of the given property (important), or an empty string when it has no priority.
GetPropertyValue(string)Returns the value of the given property, or an empty string when the property is not set.
Item(uint)Returns the name of the property at the given index, or an empty string when the index is out of range.
RemoveProperty(string)Removes the given property and returns its previous value, or an empty string when it was not set.
SetProperty(string, string?, string?)Sets the value and the priority of the given property. An empty value removes the property.
System.Collections.Generic.IReadOnlyList<System.String>.get_Item(int)
System.Collections.IEnumerable.GetEnumerator()
ToCss(CssFormatter?)Returns the text of the declarations, formatted by formatter (CssFormatter.Default when null, which returns the same text as CssStyleDeclaration.CssText).
ToCss(TextWriter, CssFormatter?)Same as CssStyleDeclaration.ToCss, but writes the text to output instead of building a string.

GetEnumerator()

CssStyleDeclaration.cs

Returns an enumerator over the names of the properties of the block.

public IEnumerator<string> GetEnumerator()

GetPropertyPriority(string)

CssStyleDeclaration.cs

Returns the priority of the given property (important), or an empty string when it has no priority.

public string GetPropertyPriority(string property)

GetPropertyValue(string)

CssStyleDeclaration.cs

Returns the value of the given property, or an empty string when the property is not set.

public string GetPropertyValue(string property)

Returns the name of the property at the given index, or an empty string when the index is out of range.

public string Item(uint index)

RemoveProperty(string)

CssStyleDeclaration.cs

Removes the given property and returns its previous value, or an empty string when it was not set.

public string RemoveProperty(string property)

SetProperty(string, string?, string?)

CssStyleDeclaration.cs

Sets the value and the priority of the given property. An empty value removes the property.

public void SetProperty(string property, string? value, string? priority = "")

System.Collections.Generic.IReadOnlyList<System.String>.get_Item(int)

string IReadOnlyList<string>.get_Item(int index)

Parameters

index int

Returns

string

No documentation is available.

System.Collections.IEnumerable.GetEnumerator()

CssStyleDeclaration.cs
IEnumerator IEnumerable.GetEnumerator()

No documentation is available.

ToCss overloads

Returns the text of the declarations, formatted by formatter (CssFormatter.Default when null, which returns the same text as CssStyleDeclaration.CssText).

public string ToCss(CssFormatter? formatter = null)
Parameters
formatter CssFormatter?
Returns

string

ToCss(TextWriter, CssFormatter?)

CssStyleDeclaration.Formatting.cs

Same as CssStyleDeclaration.ToCss, but writes the text to output instead of building a string.

public void ToCss(TextWriter output, CssFormatter? formatter = null)
Parameters
output TextWriter
formatter CssFormatter?