void|PEAR_Error HTML_CSS::setStyle (
string $element
, string $property
, string $value
, bool $duplicates
= null
)
Add or change a single value for an element property
$element
Element (or class) to be defined
$property
Property defined
$value
Value assigned
$duplicates
(optional) Allow or disallow duplicates.
throws HTML_CSS_ERROR_INVALID_INPUT
since version 0.2.0 (2003-07-31)
This function can not be called statically.
<?php
require_once 'HTML/CSS.php';
// generate an instance
$css = new HTML_CSS();
// let's set some styles for <body>
$css->setStyle('body', 'background-color', '#0c0c0c');
$css->setStyle('body', 'color', '#ffffff');
// now for <h1>
$css->setStyle('h1', 'text-align', 'center');
$css->setStyle('h1', 'font', '16pt helvetica, arial, sans-serif');
// and finally for <p>
$css->setStyle('p', 'font', '12pt helvetica, arial, sans-serif');
// let's make <body> inherit from <p>
$css->setSameStyle('body', 'p');
// and let's put this into a tag:
echo '<body style="' . $css->toInline('body') . '">';
// will output:
// <body style="font:12pt helvetica, arial, sans-serif;background-color:#0c0c0c;color:#ffffff;">
?>