CSSDeclarationBlock
Overview
CSSDeclarationBlock is a class in Aspose.Html FOSS for Python.
A small CSSStyleDeclaration-compatible declaration container.
This class provides 8 methods for working with CSSDeclarationBlock objects in Python programs.
Available methods include: __init__, get_property_priority, get_property_value, item, parse, 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 |
|---|---|---|---|
length | int | Read | Number of CSS property declarations in this block (CSSOM §6.1). |
parent_rule | "CSSRule | None" | Read | The CSSRule that owns this declaration block, or None (CSSOM §6.1). |
css_text | str | Read/Write | Canonical declaration serialization. |
Methods
| Signature | Description |
|---|---|
__init__(properties: dict[str, str] | None) | Calls init(properties) on this CSSDeclarationBlock instance. |
parse(text: str) → "CSSDeclarationBlock" | Parse a name:value declaration list. |
item(index: int) → str | Return the property name at index, or '' if out of range (CSSOM §6.1). |
get_property_priority(property_name: str) → str | Return 'important' if the property is declared !important, else ''. |
set_property_priority(property_name: str, priority: str) | Set the priority ('' or 'important') for an existing property. |
get_property_value(property_name: str) → str | Return the property value or '' when absent. |
set_property(property_name: str, value: str) | Set a property value (normal priority). |
remove_property(property_name: str) → str | Remove and return a property’s previous value, if present. |