CSSStyleDeclaration

CSSStyleDeclaration

Overview

CSSStyleDeclaration is a class in Aspose.Html FOSS for Python.

A live view of an element’s inline style attribute.

This class provides 7 methods for working with CSSStyleDeclaration objects in Python programs. Available methods include: __init__, get_property_priority, get_property_value, item, remove_property, set_property, set_property_priority. All public members are accessible to any Python application after installing the Aspose.Html FOSS for Python package. Properties: css_text, length, parent_rule.

Properties

NameTypeAccessDescription
css_textstrRead/WriteThe full inline style string (raw attribute value).
lengthintReadThe number of CSS properties in the declaration block.
parent_ruleNoneReadAlways None — inline styles have no parent rule (CSSOM §6.1).

Methods

SignatureDescription
__init__(owner_element: "Element")Calls init(owner_element) on this CSSStyleDeclaration instance.
item(index: int)strReturn the CSS property name at index, or '' if out of range.
get_property_value(property_name: str)strReturn the value of the named property, or '' if not set.
get_property_priority(property_name: str)strReturn "important" if property_name carries !important, else "".
set_property(property_name: str, value: str, priority: str)Set the named property to value, optionally with !important priority.
set_property_priority(property_name: str, priority: str)Set the priority for an existing inline property (CSSOM §6.1).
remove_property(property_name: str)strRemove the named property and return its previous value (or '').

See Also