Table of Contents

Class CSSStyleDeclaration

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The CSSStyleDeclaration interface represents an object that is a CSS declaration block, and exposes style information and various style-related methods and properties.

[Value("CSSStyleDeclaration")]
public class CSSStyleDeclaration
Inheritance
CSSStyleDeclaration
Derived
Inherited Members

Remarks

A CSSStyleDeclaration object can be exposed using three different APIs:

See also on MDN

Constructors

CSSStyleDeclaration()

public CSSStyleDeclaration()

Properties

CssText

The cssText property of the CSSStyleDeclaration interface returns or sets the text of the element's inline style declaration only.

[Value("cssText")]
public string CssText { get; set; }

Property Value

string

A string containing the text of the element's inline style declaration.

Remarks

To be able to set a stylesheet rule dynamically, see Using dynamic styling information.

Not to be confused with stylesheet style-rule CssText.

See also on MDN

Length

The read-only property returns an integer that represents the
number of style declarations in this CSS declaration block.

[Value("length")]
public ulong Length { get; }

Property Value

ulong

An integer that provides the number of styles explicitly set on the parent of
the instance.

Remarks

ParentRule

The CSSStyleDeclaration.parentRule read-only
property returns a 'CSSRule' that is the parent of this style
block, e.g., a 'CSSStyleRule' representing the style for a CSS
selector.

[Value("parentRule")]
public CSSRule? ParentRule { get; }

Property Value

CSSRule

The CSS rule that contains this declaration block or null if this
'CSSStyleDeclaration' is not attached to a 'CSSRule'.

Remarks

Methods

GetPropertyPriority(string)

The CSSStyleDeclaration.getPropertyPriority() method interface returns
a string that provides all explicitly set priorities on the CSS
property.

[Value("getPropertyPriority")]
public string GetPropertyPriority(string property)

Parameters

property string

Returns

string

A string that represents the priority (e.g., "important") if one exists.
If none exists, returns the empty string.

Remarks

GetPropertyValue(string)

The CSSStyleDeclaration.getPropertyValue() method interface returns a string containing the value of a specified CSS property.

[Value("getPropertyValue")]
public string GetPropertyValue(string property)

Parameters

property string

Returns

string

A string containing the value of the property. If not set, returns the empty string.The property value is dynamically computed, not what was originally specified in the declaration. The serialization happens in the following way:In essence, the property value is canonicalized, ensuring that two property values with the same rendering effect compare equal even when they are declared differently.

Remarks

RemoveProperty(string)

The CSSStyleDeclaration.removeProperty() method interface
removes a property from a CSS style declaration object.

[Value("removeProperty")]
public string RemoveProperty(string property)

Parameters

property string

Returns

string

A string equal to the value of the CSS property before it was removed.

Remarks

SetProperty(string, string, string)

The
CSSStyleDeclaration.setProperty() method interface sets
a new value for a property on a CSS style declaration object.

[Value("setProperty")]
public GlobalObject.Undefined SetProperty(string property, string value, string priority = null)

Parameters

property string
value string
priority string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks