<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>OOCSS: Object Oriented CSS v1.0</title>
<link rel='stylesheet' type='text/css' href='styles.oocss' />
</head>
<body>
<!--
Object Oriented CSS v1.0
August 2, 2009
Corey Hart @ http://www.codenothing.com
-->
<h1>OOCSS: Object Oriented CSS v1.0</h1>
<p>
Object Oriented CSS is a new way to write CSS files to speed up development
by using parent relations and variable storage.
</p>
<p>
Nothing is easy to explain without an example, so I've included the stylesheet
used on this page below.
</p>
<table><tr>
<td width=600>
Unparsed <a href='styles.oocss'>styles.oocss</a>
<pre><?= htmlspecialchars(file_get_contents(dirname(__FILE__).'/styles.oocss'), ENT_QUOTES) ?></pre>
</td>
<td>
Parsed <a href='styles.oocss'>styles.oocss</a>
<iframe src='styles.oocss'></iframe>
</td>
</tr></table>
<p>
OOCSS takes what would normally be a painfully large, unintuitive style sheet,
and turns it into less code for better maintenance. All parsed scripts are cached
server side.
</p>
<h2>How it Works</h2>
<h4>Variables</h4>
<p>
OOCSS can parse both single and multiple definition varaibles. Single definition varibales
must follow the following pattern:
<code>$var = prop:value;</code>
You can think of multiple definitions as an array. The array must be be enclosed
in brackets trailed by a semi-colon, with each definition seperated by a comma. Ex:
<code>$multi_var = { prop1:value1, prop2:value2, prop3:value3 }</code>
When using a variable, they must be followed by a semi-colon, or they will not be replaced
with their values.
</p>
<h4>Parsing</h4>
<p>
The file is parsed like a DOM Tree, where inner elements are considered children of
the wrapped element. If you set the OOCSS_DEBUG_MODE defined variable to true, you can
get a better picture of what variables are being stored, and how the tree looks. Here's
what this pages stylesheet tree looks like:
</p>
<pre>Tree Parsed: Array
(
[body] => Array
(
[props] => Array
(
[0] => font-size: 10pt;
[1] => margin: 0;
[2] => padding: 0;
)
)
[pre] => Array
(
[props] => Array
(
[0] => display: block;
[1] => border: 1px dashed #595959;
[2] => height: 200px;
[3] => background-color: #f1f1f1;
[4] => overflow: auto;
[5] => width: 500px;
[6] => margin: 0 0 40px 0;
[7] => font-size: 9pt ;
[8] => margin-left: 15px;
)
)
[h4] => Array
(
[props] => Array
(
[0] => background-color: #989898;
[1] => padding: 5px;
[2] => margin: 0;
[3] => width: 600px;
[4] => color: white;
)
)
[p >] => Array
(
[props] => Array
(
[0] => width: 600px;
[1] => padding-left: 10px;
)
[code] => Array
(
[props] => Array
(
[0] => display: block;
[1] => border: 1px dashed #595959;
[2] => background-color: #f1f1f1;
[3] => overflow: auto;
[4] => margin: 15px;
[5] => padding: 5px;
[6] => font-size: 9pt;
)
)
[a] => Array
(
[props] => Array
(
[0] => color: blue;
[1] => text-decoration: none ;
)
)
)
[table] => Array
(
[props] => Array
(
[0] => margin-top: 20px;
)
[pre] => Array
(
[props] => Array
(
[0] => display: block;
[1] => border: 1px dashed #595959;
[2] => height: 200px;
[3] => background-color: #f1f1f1;
[4] => overflow: auto;
[5] => width: 500px;
[6] => margin: 0 0 40px 0;
[7] => font-size: 9pt ;
)
)
[iframe] => Array
(
[props] => Array
(
[0] => display: block;
[1] => border: 1px dashed #595959;
[2] => height: 200px;
[3] => background-color: #f1f1f1;
[4] => overflow: auto;
[5] => width: 500px;
[6] => margin: 0 0 40px 0;
[7] => font-size: 9pt ;
)
)
[td] => Array
(
[> a] => Array
(
[props] => Array
(
[0] => color: blue;
[1] => text-decoration: none ;
)
)
)
)
)
</pre>
<p>
To prevent long loads, parsed files are cached into a seperate directory. The files are
stored using a combination of both oocss.php and your oocss last change times, so you
can be assured that any changes made will be automatically parsed.
</p>
<div id='footer'>
Have any questions? Found a bug? <a href='mailto:hide@address.com?Subject=OOCSS Question/Bug'>Let me know</a>
</div>
</body>
</html>