====================
CSSStyleDeclaration
====================
:author: $LastChangedBy: cthedot $
:date: $LastChangedDate: 2007-08-08 16:14:03 +0200 (Mi, 08 Aug 2007) $
:version: 0.9.2b4, $LastChangedRevision: 206 $

`Index <../index.txt>`_

.. contents::

random notes about style declarations
=====================================

CSSStyleDeclaration is iterable (**experimental**). The iterator returns  *all* properties set in this style as objects with properties ``name``, ``cssValue`` and ``priority``. Calling CSSStyleDeclaration.item(index) on the other hand simply returns a property name and also only the normalized name (once). Example::

    
    sheet = cssutils.parseString('a { color: red; c\olor: blue; left: 0 !important }')
    for rule in sheet.cssRules:
        style = rule.style
        for property in style:
            name = property.name
            cssValue = property.cssValue
            priority = property.priority
            print name, '=', cssValue.cssText, priority
            
        # prints:
        # color = red
        # c\olor = blue
        # left = 0 !important

        for i in range(0, style.length):
            name = style.item(i)
            cssValue = style.getPropertyCSSValue(name)
            priority = style.getPropertyPriority(name)
            print name, '=', cssValue.cssText , priority

        # prints:
        # color = blue
        # left = 0 !important