PEAR logo

HTML_CSS : The Definitive Guide

Chapter 9. API - Application Programming Interface

Table of Contents

Initialize parser/writer options
Handle selector and property values
Grouping selectors
Parsing data sources
Output
Searching for selectors and/or properties

Initialize parser/writer options

constructor HTML_CSS::HTML_CSS - Class constructor
HTML_CSS::setXhtmlCompliance - Sets XHTML compliance
HTML_CSS::setCache - Defines if the document should be cached by the browser. Defaults to false.
HTML_CSS::setSingleLineOutput - Determines whether definitions are output single line or multiline
HTML_CSS::setOutputGroupsFirst - Determines whether groups are output before elements or not

With the class constructor, you have ability to set many options :

  • xhtml option defines whether element selectors should be automatically lowercased. See also: HTML_CSS::setXhtmlCompliance().
  • tab option defines the string used to indent CSS text. See also: HTML_Common::setTab().
  • filename option allow to parse an external css file. See also: HTML_CSS::parseFile().
  • cache option controls caching of the page. See also: HTML_CSS::setCache().
  • oneline option defines whether to output all properties on one line. See also: HTML_CSS::setSingleLineOutput().
  • groupsfirst option determines whether to output groups before elements. See also: HTML_CSS::setOutputGroupsFirst().
  • allowduplicates option allow to have duplicate rules in selector.
[Tip] Tip
HTML_CSS 1.4.0+ users may now set a single option directly like that:
  1. <?php
  2. require_once 'HTML/CSS.php';
  3.  
  4. $css = new HTML_CSS();
  5.  
  6. // with PHP5 only
  7. $css->allowduplicates = true;
  8.  
  9. // with PHP4 only
  10. $css->__set('allowduplicates', true);
  11. ?>
HTML_CSS : The Definitive Guide v 1.4.0 : December 14, 2007