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
| Name | Type | Access | Description |
|---|---|---|---|
css_text | str | Read/Write | The full inline style string (raw attribute value). |
length | int | Read | The number of CSS properties in the declaration block. |
parent_rule | None | Read | Always None — inline styles have no parent rule (CSSOM §6.1). |
Methods
| Signature | Description |
|---|---|
__init__(owner_element: "Element") | Calls init(owner_element) on this CSSStyleDeclaration instance. |
item(index: int) → str | Return the CSS property name at index, or '' if out of range. |
get_property_value(property_name: str) → str | Return the value of the named property, or '' if not set. |
get_property_priority(property_name: str) → str | Return "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) → str | Remove the named property and return its previous value (or ''). |