SPHPlayground manual

HTML attribute management


An HTML attribute is a modifier of an HTML element. Particular attributes are only supported by particular element types.

Some attributes are required attributes, needed by particular element types for them to function correctly; while in other cases they are optional attributes. Standard attributes are supported by a large number of element types.

HTML attribute implementations

All HTML attributes implement Attribute interface. Frameework defines also MutableAttribute interface from which most build-in atttributes are implemented.

Instantiable attribute classes:

Invalid value for 'type' attribute

Attribute management with an AttributeContainer

The AttributeContainer provides methods for creating, storing and manipulating Attribute objects. It is used in all of the HTML components as the attribute handler.

Basic AttributeContainer methods:

  1. setAttribute(): sets an attribute object
  2. remove(): removes an attribute if possible
  3. forceVisibility(): This method sets an attribute as always visible (atleast attribute name). A previously nonexistent required attribute is stored to the manager as an empty attribute. A required attribute cannot be removed, but its value is still mutable.
  4. protect(): This method locks an attribute to a given value. Such attribute cannot be removed and locked value is immune to modification.


  1. As default the style and class attributes can have multiple locked values (Style properties and CSS class names) at the same time and only the locked .
  2. other attributes can have only one value as locked at the same time.
  3. Attribute can be required and have a locked value at the same time.