CSSDeclarationBlock

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

NameTypeAccessDescription
lengthintReadNumber of CSS property declarations in this block (CSSOM §6.1).
parent_rule"CSSRule | None"ReadThe CSSRule that owns this declaration block, or None (CSSOM §6.1).
css_textstrRead/WriteCanonical declaration serialization.

Methods

SignatureDescription
__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)strReturn the property name at index, or '' if out of range (CSSOM §6.1).
get_property_priority(property_name: str)strReturn '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)strReturn the property value or '' when absent.
set_property(property_name: str, value: str)Set a property value (normal priority).
remove_property(property_name: str)strRemove and return a property’s previous value, if present.

See Also