FAQ – Answers to most Frequently Asked Questions


What does it cost ?

You can download and use it for free. But don't delete the copyright notice. You can read terms of the license.

Do you offer support ?

YES if there is no answer in this Guide and if you are ready to share some informations such as : your configuration (platform Win *nix mac, PHP version, PEAR packages installed) and perharps your script.

I found a bug, what shall I do ?

You can report it with the bug tracker at PEAR.

What is CSS ?

CSS (an acronym for Cascading Style Sheets) is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.

HTML_CSS is a PEAR package that provides methods for handling stylesheet declarations.

Version 1.0.0 does not offers yet methods to validate a style sheet.

What is PEAR ?

PEAR (an acronym for PHP Extension and Application Repository) is a framework and distribution system for reusable PHP components.

Don't forget to read also the PEAR Manual and PEAR FAQ.

I want to use HTML_CSS without PEAR. Is it possible ?

Yes it is. First, you need to download package PEAR::HTML_Common version 1.2 or greater.

Extract content (Common.php file) in same directory HTML/ as CSS.php file.

Last, you should create your own error handler, or disable it. See chapter Error Handler for details.

I want to know property value of a selector, but it can not exist

With previous release than 1.1.0 it was not possible because HTML_CSS::getStyle() require at least an existing property, or it will return HTML_CSS_ERROR_NO_ELEMENT_PROPERTY.

With new function HTML_CSS::grepStyle() of version 1.1.0, it's now possible.

01: <?php
: require_once 'HTML/CSS.php';
04: function myErrorHandler()
05: {
06:     return PEAR_ERROR_PRINT;  // always print all error messages
07: }
09$styles '
10: h1, h2, h3, h4 { padding: 1em; }
11: .highlight p, .highlight ul { margin-left: .5em; }
12: #main p, #main ul { padding-top: 1em; }
13: '
15$prefs = array(
16:     'push_callback' => 'myErrorHandler',
17: );
18$attribs null;
20$css = new HTML_CSS($attribs$prefs);
23$css->getStyle('.highlight p''color');
25$styles $css->grepStyle('/highlight/''/^color$/');
26: echo '<pre>'var_dump($styles); echo '</pre>';
Lines 4-7, 15-17, 20 :

Custom error handler is defined to allow script to continue (print message), when HTML_CSS::getStyle() will raise error at line 23.

Lines 9-13, 21 :

Stylesheet used is :

h1, h2, h3, h4 { padding: 1em; }
.highlight p, .highlight ul { margin-left: .5em; }
#main p, #main ul { padding-top: 1em; }
Lines 23, 25 :

While HTML_CSS::getStyle() will raise error (printed by custom error handler), line 25 will return an empty array with no error raised.

Reason : color property does not exist for .highlight p class selector.

About (Previous) What is New in version ? (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.