ICSSStyleDeclaration Interface
ICSSStyleDeclaration interface
The CSSStyleDeclaration interface represents an object that is a CSS declaration block, and exposes style information and various style-related methods and properties.
A CSSStyleDeclaration object can be exposed using three different APIs:
Via HTMLElement.style, which deals with the inline styles of a single element.Via the CSSStyleSheet
API. For example, document.styleSheets[0].cssRules[0].style returns a CSSStyleDeclaration
object on the first CSS rule in the document’s first stylesheet.Via Window.getComputedStyle(), which exposes the CSSStyleDeclaration
object as a read-only interface.
public interface ICSSStyleDeclaration : ICSS2Properties, IEnumerable<String>
Properties
Name | Description |
---|---|
[getCSSText] | |
[setCSSText] The parsable textual representation of the declaration block (excluding the surrounding curly braces). Setting this attribute will result in the parsing of the new value and resetting of all the properties in the declaration block including the removal or addition of properties. | |
getItem Used to retrieve the properties that have been explicitly set in this declaration block. The order of the properties retrieved using this method does not have to be the order in which they were set. This method can be used to iterate over all properties in this declaration block. | |
getLength The read-only property returns an integer number of properties that have been explicitly set in this CSS declaration block. The range of valid indices is 0 to length-1 inclusive. | |
getParentRule 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. |
Methods
Name | Description |
---|---|
getPropertyCSSValue(String) | Used to retrieve the object representation of the value of a CSS property if it has been explicitly set within this declaration block. This method returns null if the property is a shorthand property. Shorthand property values can only be accessed and modified as Strings, using the getPropertyValue and setProperty methods. |
getPropertyPriority(String) | Used to retrieve the priority of a CSS property (e.g. the “important” qualifier) if the property has been explicitly set in this declaration block. |
getPropertyValue(String) | The CSSStyleDeclaration.getPropertyValue() method interface returns a String containing the value of a specified CSS property. |
removeProperty(String) | The CSSStyleDeclaration.removeProperty() method interface removes a property from a CSS style declaration object. |
setProperty(String, String) | The CSSStyleDeclaration.setProperty() method interface is used to set a property value with default priority within this declaration block. Default priority is not “important” i.e. String.Empty |
setProperty(String, String, String) | The CSSStyleDeclaration.setProperty() method interface is used to set a property value with default priority within this declaration block. Default priority is not “important” i.e. String.Empty |
Remarks
CSSOM defines APIs (including generic parsing and serialization rules) for Media Queries, Selectors, and of course CSS itself.
Reference
CSS Working Group - The CSS Working Group is the W3C working group chartered to develop Cascading Style Sheets (CSS).CSS Object Model (CSSOM) - CSSOM defines APIs (including generic parsing and serialization rules) for Media Queries, Selectors, and of course CSS itself.CSS Object Model (CSSOM) # cssstyledeclaration – The CSSOM definition.
See Also
- interface ICSS2Properties
- package com.aspose.html.Dom.Css
- package Aspose.HTML