Interface CSSStyleDeclaration

All Known Subinterfaces:
CSSComputedProperties, NodeStyleDeclaration
All Known Implementing Classes:
AbstractCSSStyleDeclaration, AnonymousStyleDeclaration, BaseCSSStyleDeclaration, CompatInlineStyle, ComputedCSSStyle, DOMComputedStyle, InlineStyle

public interface CSSStyleDeclaration
CSS style declaration.
  • Method Summary

    Modifier and Type
    Method
    Description
    A parsable serialization of the declaration.
    int
    The number of properties in this declaration.
    A minified parsable textual representation of the declaration.
    Retrieves the CSS rule that contains this declaration block.
    Gets the object representation of the value of a CSS property if it has been explicitly set for this declaration block.
    Get the priority that was set to the given property in this declaration.
    getPropertyValue(String propertyName)
    Gets the text value of a CSS property if it has been explicitly set within this declaration block.
    item(int index)
    The name of the property at index index in this declaration.
    removeProperty(String propertyName)
    Remove the given property from this declaration.
    void
    setCssText(String cssText)
    Parse the given text, and set the contents of this declaration according to it.
    void
    setProperty(String propertyName, String value, String priority)
    Set the value of a property in this declaration, with the given priority.
    void
    Writes a textual representation of the declaration block (excluding the surrounding curly braces) to a SimpleWriter, and according to a StyleFormattingContext.
  • Method Details

    • getCssText

      String getCssText()
      A parsable serialization of the declaration.
      Returns:
      the textual representation of the declaration.
    • getMinifiedCssText

      String getMinifiedCssText()
      A minified parsable textual representation of the declaration.
      Returns:
      the minified textual representation of the declaration.
    • setCssText

      void setCssText(String cssText) throws DOMException
      Parse the given text, and set the contents of this declaration according to it.
      Parameters:
      cssText - the serialized style declaration.
      Throws:
      DOMException
    • removeProperty

      String removeProperty(String propertyName) throws DOMException
      Remove the given property from this declaration.
      Parameters:
      propertyName - the name of the property to remove.
      Returns:
      the value of the removed property, or the empty string if that property was not explicitly set in this declaration.
      Throws:
      DOMException
    • getPropertyPriority

      String getPropertyPriority(String propertyName)
      Get the priority that was set to the given property in this declaration.
      Parameters:
      propertyName - the name of the property.
      Returns:
      the priority string, or the empty string if no priority was set.
    • setProperty

      void setProperty(String propertyName, String value, String priority) throws DOMException
      Set the value of a property in this declaration, with the given priority.
      Parameters:
      propertyName - the name of the property.
      value - the property value.
      priority - the priority.
      Throws:
      DOMException
    • getLength

      int getLength()
      The number of properties in this declaration.
      Returns:
      the number of properties in this declaration.
    • item

      String item(int index)
      The name of the property at index index in this declaration.
      Parameters:
      index - the index.
      Returns:
      the name of the property at the given index, or null if the index is less than zero, or greater or equal to the length of this declaration.
    • getPropertyCSSValue

      CSSValue getPropertyCSSValue(String propertyName)
      Gets the object representation of the value of a CSS property if it has been explicitly set for this declaration block.

      If the declaration was created by a factory with the IEVALUES flag enabled, the compatibility values shall appear in the cssText serializations, but its value won't be returned by this method unless no other valid value was previously specified for the property.

      Parameters:
      propertyName - The name of the CSS property.
      Returns:
      the value of the property if it has been explicitly set for this declaration block. Returns null if the property has not been set or is a shorthand.
    • getPropertyValue

      String getPropertyValue(String propertyName)
      Gets the text value of a CSS property if it has been explicitly set within this declaration block.

      If the declaration was created by a factory with the IEVALUES flag enabled, the compatibility values shall appear in the cssText serializations, but its value won't be returned by this method unless no other valid value was previously specified for the property.

      Parameters:
      propertyName - The name of the CSS property.
      Returns:
      the value of the property if it has been explicitly set for this declaration block, or the empty string if the property has not been set or is a shorthand that could not be serialized.
    • getParentRule

      CSSDeclarationRule getParentRule()
      Retrieves the CSS rule that contains this declaration block.
      Returns:
      the CSS rule that contains this declaration block or null if this CSSStyleDeclaration is not attached to a CSSRule.
    • writeCssText

      void writeCssText(SimpleWriter wri, StyleFormattingContext context) throws IOException
      Writes a textual representation of the declaration block (excluding the surrounding curly braces) to a SimpleWriter, and according to a StyleFormattingContext.
      Parameters:
      wri - the simple writer to write to.
      context - the style formatting context.
      Throws:
      IOException - if a problem occurs while writing the text.