PEAR logo

HTML_CSS : The Definitive Guide

Parse a simple string

A quick way to create multiple selector definitions in one step is to use the HTML_CSS::parseString() function.

Let creates these definitions :

  1. html, body {
  2.   margin: 2px;
  3.   padding: 0px;
  4.   border: 0px;
  5. }
  6.  
  7. p, body {
  8.   margin: 4px;
  9. }

Very easy with such script :

  1. <?php
  2. require_once 'HTML/CSS.php';
  3.  
  4. $css = new HTML_CSS();
  5.  
  6. $strcss = '
  7. html, body {
  8.  margin: 2px;
  9.  padding: 0px;
  10.  border: 0px;
  11. }
  12.  
  13. p, body {
  14.  margin: 4px;
  15. }
  16. ';
  17. $css->parseString($strcss);
  18.  
  19. $css->display();
  20. ?>
HTML_CSS : The Definitive Guide v 1.5.0 : January 15, 2008