PEAR logo

HTML_CSS : The Definitive Guide

Searching for a group of selectors

Let creates these definitions into progress2.css file :

  1. #PB1.cellPB1I, #PB1.cellPB1A {
  2.   width: 15px;
  3.   height: 20px;
  4.   font-family: Courier, Verdana;
  5.   font-size: 8px;
  6.   float: left;
  7. }
  8.  
  9. #PB1.progressBorderPB1 {
  10.   width: 172px;
  11.   height: 24px;
  12.   border-width: 1px;
  13.   border-style: solid;
  14.   border-color: #404040 #dfdfdf #dfdfdf #404040;
  15.   background-color: #CCCCCC;
  16. }
  17.  
  18. .progressPercentLabelpct1PB1 {
  19.   width: 50px;
  20.   text-align: right;
  21.   background-color: transparent;
  22.   font-size: 11px;
  23.   font-family: Verdana, Tahoma, Arial;
  24.   font-weight: normal;
  25.   color: #000000;
  26. }
  27.  
  28. .progressTextLabeltxt1PB1 {
  29.   text-align: left;
  30.   background-color: transparent;
  31.   font-size: 11px;
  32.   font-family: Verdana, Tahoma, Arial;
  33.   font-weight: normal;
  34.   color: #000000;
  35. }
  36.  
  37. .cellPB1I {
  38.   background-color: #CCCCCC;
  39. }
  40.  
  41. .cellPB1A {
  42.   background-color: #0033FF;
  43. }
  44.  
  45. body {
  46.     background-color: #E0E0E0;
  47.     color: #000000;
  48.     font-family: Verdana, Arial;
  49. }

Very easy with such script to find where is declared #PB1 class selectors (names like).

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