1CSS::DOM::Style(3) User Contributed Perl Documentation CSS::DOM::Style(3)
2
3
4
6 CSS::DOM::Style - CSS style declaration class for CSS::DOM
7
9 Version 0.17
10
12 use CSS::DOM::Style;
13
14 $style = CSS::DOM::Style::parse(' text-decoration: none ');
15
16 $style->cssText; # returns 'text-decoration: none'
17 $style->cssText('color: blue'); # replace contents
18
19 $style->getPropertyValue('color'); # 'blue'
20 $style->color; # same
21 $style->setProperty(color=>'green'); # change it
22 $style->color('green'); # same
23
25 This module provides the CSS style declaration class for CSS::DOM. (A
26 style declaration is what comes between the braces in "p { margin: 0
27 }".) It implements the CSSStyleDeclaration DOM interface.
28
30 CSS::DOM::Style::parse( $string )
31 CSS::DOM::Style::parse( $string, property_parser => $parser )
32 This parses the $string and returns a new style declaration object.
33 This is useful if you have text from an HTML "style" attribute, for
34 instance.
35
36 For details on $property_parser, see CSS::DOM::PropertyParser.
37
38 new CSS::DOM::Style $owner_rule
39 new CSS::DOM::Style owner => $owner_rule, property_parser => $p
40 You don't normally need to call this, but, in case you do, here it
41 is. $owner_rule, which is optional, is expected to be a
42 CSS::DOM::Rule object, or a subclass like CSS::DOM::Rule::Style.
43
45 cssText ( $new_value )
46 Returns the body of this style declaration (without the braces). If
47 you pass an argument, it will parsed and replace the existing CSS
48 data.
49
50 getPropertyValue ( $name )
51 Returns the value of the named CSS property as a string.
52
53 getPropertyCSSValue ( $name )
54 Returns an object representing the property's value. (See
55 CSS::DOM::Value.)
56
57 removeProperty ( $name )
58 Removes the named property, returning its value.
59
60 getPropertyPriority
61 Returns the property's priority. This is usually the empty string
62 or the word 'important'.
63
64 setProperty ( $name, $value, $priority )
65 Sets the CSS property named $name, giving it a value of $value and
66 setting the priority to $priority.
67
68 length
69 Returns the number of properties
70
71 item ( $index )
72 Returns the name of the property at the given index.
73
74 parentRule
75 Returns the rule to which this declaration belongs.
76
77 modification_handler ( $coderef )
78 This method, not part of the DOM, allows you to attach a call-back
79 routine that is run whenever a change occurs to the style object
80 (with the style object as its only argument). If you call it
81 without an argument it returns the current handler. With an
82 argument, it returns the old value after setting it.
83
84 property_parser
85 This returns the parser that was passed to the constructor.
86
87 This module also has methods for accessing each CSS property directly.
88 Simply capitalise each letter in a CSS property name that follows a
89 hyphen, then remove the hyphens, and you'll have the method name. E.g.,
90 call the "borderBottomWidth" method to get/set the border-bottom-width
91 property. One exception to this is that "cssFloat" is the method used
92 to access the 'float' property. (But you can also use the "float"
93 method, though it's not part of the DOM standard.)
94
96 CSS::DOM
97
98 CSS::DOM::Rule::Style
99
100 CSS::DOM::PropertyParser
101
102 HTML::DOM::Element
103
104
105
106perl v5.30.1 2020-01-29 CSS::DOM::Style(3)