PEAR logo

HTML_CSS : The Definitive Guide

Searching for selectors that set a property

We still used the CSS definitions of previous example, identified by progress2.css file :

Very easy with such script to find where is declared color property.

  1. <?php
  2. require_once 'HTML/CSS.php';
  3.  
  4. $css = new HTML_CSS();
  5. $css->parseFile('progress2.css');
  6.  
  7. // find all selectors that set the color property
  8. $styles = $css->grepStyle('/./', '/^color$/');
  9. echo '<pre>'; var_dump($styles); echo '</pre>';
  10. ?>
HTML_CSS : The Definitive Guide v 1.5.0 : January 15, 2008