HTML_CSS : The Definitive Guide
|
We have already seen two single sources where CSS data could come from. The last one allow to parse data from multiple sources at once.
HTML_CSS::parseData() function take an array as first argument. Each item is either a filename (with .css extension) or a string. Each source is merge to produce at end a unique style sheet.
In script below we load selector definitions from two independent sources: a string and a css file which contents duplicate definitions (parseFile() 2nd argument to set to true to catch this situation; see next section for explains). Internet Explorer).
<?php
require_once 'HTML/CSS.php';
$css = new HTML_CSS();
// 1. a string to parse
$strcss = '
body, p { background-color: white; font: 1.2em Arial; }
p, div#black { color: black; }
div{ color: green; }
p { margin-left: 3em; }
';
$css->parseString($strcss);
// 2. a css file with duplicate definitions
$css->parseFile('iehack.css', true);
$css->display();
?>
| HTML_CSS : The Definitive Guide | v 1.0.0 : June 24, 2006 |