Simple
selectors with one or more property
This example give you ability to define some styles from scratch
and produce a simple style sheet output directly to browser.
Here is the result we should expected :
-
body {
-
background-color:
#0c0c0c;
-
color: #ffffff;
-
}
-
-
h1 {
-
text-align: center;
-
font: 16pt helvetica, arial, sans-serif;
-
}
-
-
p {
-
font: 12pt helvetica, arial, sans-serif;
-
}
Example 11.1. Simple selector definitions
-
<?php
-
require_once 'HTML/CSS.php';
-
-
$css = new HTML_CSS();
-
-
// define styles
-
$css->setStyle('body', 'background-color', '#0c0c0c');
-
$css->setStyle('body', 'color',
'#ffffff');
-
$css->setStyle('h1', 'text-align',
'center');
-
$css->setStyle('h1', 'font',
'16pt helvetica, arial,
sans-serif');
-
$css->setStyle('p', 'font',
'12pt helvetica, arial,
sans-serif');
-
-
// output the stylesheet directly to
browser
-
$css->display();
-
?>
Combine
selectors with one or more property
This example give you ability to define another selector with same
properties as the previous one already defined. The simple style
sheet is output directly to browser.
Here p
and div#black
selectors share the same properties.
Here is the result we should expected :
-
p, div#black {
-
font: 12pt helvetica, arial, sans-serif;
-
}
Example 11.2. Combine selectors properties
-
<?php
-
require_once 'HTML/CSS.php';
-
-
$css = new HTML_CSS();
-
-
// define styles
-
$css->setStyle('p', 'font',
'12pt helvetica, arial,
sans-serif');
-
$css->setSameStyle('div#black',
'p');
-
-
// output the stylesheet directly to
browser
-
$css->display();
-
?>