CssStyleDeclaration Class
https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface
public class CssStyleDeclaration : IEnumerable<string>, IReadOnlyCollection<string>, IReadOnlyList<string>, IEnumerableProperties
| Name | Description |
|---|---|
| Count | Gets the number of declarations in the block. |
| CssText | Gets or sets the serialization of the declaration block. Setting the value replaces all the declarations. |
| Length | Gets the number of declarations in the block. |
| ParentRule | Gets the rule that contains the declaration block, or null when the block is not in a rule. |
CssText
CssStyleDeclaration.csGets or sets the serialization of the declaration block. Setting the value replaces all the declarations.
public string CssText { get; set; }Length
CssStyleDeclaration.csGets the number of declarations in the block.
public uint Length { get; }ParentRule
CssStyleDeclaration.csGets the rule that contains the declaration block, or null when the block is not in a rule.
public CssRule? ParentRule { get; }Indexers
| Name | Description |
|---|---|
| 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
this[int]
CssStyleDeclaration.csthis[uint]
CssStyleDeclaration.csGets the name of the property at the given index, or an empty string when the index is out of range.
Methods
| Name | Description |
|---|---|
| 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.csReturns an enumerator over the names of the properties of the block.
public IEnumerator<string> GetEnumerator()Returns
GetPropertyPriority(string)
CssStyleDeclaration.csReturns the priority of the given property (important), or an empty string when it has no priority.
GetPropertyValue(string)
CssStyleDeclaration.csReturns the value of the given property, or an empty string when the property is not set.
Item(uint)
CssStyleDeclaration.csReturns the name of the property at the given index, or an empty string when the index is out of range.
RemoveProperty(string)
CssStyleDeclaration.csRemoves the given property and returns its previous value, or an empty string when it was not set.
SetProperty(string, string?, string?)
CssStyleDeclaration.csSystem.Collections.Generic.IReadOnlyList<System.String>.get_Item(int)
System.Collections.IEnumerable.GetEnumerator()
CssStyleDeclaration.csToCss overloads
ToCss(CssFormatter?)
CssStyleDeclaration.Formatting.csReturns 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)ToCss(TextWriter, CssFormatter?)
CssStyleDeclaration.Formatting.csSame as CssStyleDeclaration.ToCss, but writes the text to output instead of building a string.
public void ToCss(TextWriter output, CssFormatter? formatter = null)Parameters
outputTextWriterformatterCssFormatter?