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
Checking data sources
Output
Searching for selectors and/or properties
Handle At-Rules

Initialize parser/writer options

constructor HTML_CSS::HTML_CSS - Class constructor
HTML_CSS::setXhtmlCompliance - Set xhtml flag
HTML_CSS::setCache - Set cache flag
HTML_CSS::getCharset - Return the charset encoding string
HTML_CSS::setCharset - Set charset value
HTML_CSS::setTab - Set tab value
HTML_CSS::setLineEnd - Set lineend value
HTML_CSS::setSingleLineOutput - Set oneline flag
HTML_CSS::setOutputGroupsFirst - Set groupsfirst flag

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_CSS::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() .

  • charset option defines the character encoding string. See also: HTML_CSS::setCharset() .

  • contentDisposition option contains the Content-Disposition filename. See also: HTML_CSS::setContentDisposition() .

  • lineEnd option sets the line end style to Windows, Mac, Unix or a custom string. See also: HTML_CSS::setLineEnd() .

  • 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 use
  10. $css->__set('allowduplicates', true);
  11. ?>
HTML_CSS : The Definitive Guide v 1.5.0 : January 15, 2008