cvs: peardoc /en/package/html html-css.xml /en/package/html/html-css intro.xml

From: Date: Thu, 22 Jan 2009 09:49:27 +0000
Subject: cvs: peardoc /en/package/html html-css.xml /en/package/html/html-css intro.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-11458@lists.php.net to get a copy of this message
farell Thu Jan 22 09:49:27 2009 UTC Added files: /peardoc/en/package/html/html-css intro.xml Modified files: /peardoc/en/package/html html-css.xml Log: phase2: continue to include my external doc (TDG) => Getting Started -> Overview -> Basic Concepts

http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-css.xml?r1=1.15&r2=1.16&diff_format=u Index: peardoc/en/package/html/html-css.xml diff -u peardoc/en/package/html/html-css.xml:1.15 peardoc/en/package/html/html-css.xml:1.16 --- peardoc/en/package/html/html-css.xml:1.15 Wed Jan 21 09:40:29 2009 +++ peardoc/en/package/html/html-css.xml Thu Jan 22 09:49:17 2009 @@ -117,6 +117,12 @@ </section> </chapter> + <chapter xml:id="package.html.html-css.tutorial"> + <info><title>Getting started</title></info> + + &package.html.html-css.intro; + </chapter> + <chapter xml:id="package.html.html-css.ref"> <info><title>Reference guide</title></info> http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-css/intro.xml?view=markup&rev=1.1 Index: peardoc/en/package/html/html-css/intro.xml +++ peardoc/en/package/html/html-css/intro.xml <?xml version="1.0" encoding="utf-8"?> <refentry xmlns="http://docbook.org/ns/docbook" version="lillet" xml:id="package.html.html-css.intro"> <refnamediv> <refname>Overview</refname> <refpurpose>features and usage patterns</refpurpose> </refnamediv> <refsection xml:id="package.html.html-css.intro.purpose"> <info><title>In brief</title></info> <simpara> The purpose of this tutorial is to give the new users of HTML_CSS an overview of its features and usage patterns. It describes a small subset of available functionality, but points to the parts of the documentation that give a more in-depth overview. </simpara> <simpara> Selectors are one of the most important aspects of CSS as they are used to "select" elements on an HTML page so that they can be styled. We will try to explain basic concepts, and how to do the same with HTML_CSS. </simpara> <para> A complete tutorial about CSS selectors can be find at <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://css.maxdesign.com.au/index.htm"> maxDesign </link>. </para> </refsection> <refsection xml:id="package.html.html-css.intro.concepts"> <info><title>Basic concepts</title></info> <refsection xml:id="package.html.html-css.intro.concepts.what-is-rule"> <info><title>What is a rule or "rule set" ?</title></info> <simpara> A rule or "rule set" is a statement that tells browsers how to render particular elements on an HTML page. A rule set consists of a selector followed by a declaration block. </simpara> </refsection> <refsection xml:id="package.html.html-css.intro.concepts.ruleset"> <info><title>Rule set structure</title></info> <para> TODO: integration of picture -&gt; http://www.laurent-laville.org/pear/HTML_CSS/docs/TDG/en/img/rule.gif </para> </refsection> <refsection xml:id="package.html.html-css.intro.concepts.declaration-block"> <info><title>Declaration block</title></info> <para> The <methodname>HTML_CSS::setStyle()</methodname> method is the only one to handle a declaration block. </para> <para> For example, to declare a such rule : <programlisting role="css"> p { padding: 5px; } </programlisting> </para> <para> Here is the php code to create the same sentence with HTML_CSS : <programlisting role="php"> <![CDATA[ <?php require_once 'HTML/CSS.php'; $css = new HTML_CSS(); $css->setStyle('p', 'padding', '5px'); $css->display(); ?> ]]> </programlisting> </para> </refsection> <refsection xml:id="package.html.html-css.intro.concepts.declaration-group"> <info><title>Grouping declarations</title></info> <simpara> You can use more than one declaration within a declaration block. Each declaration must be separated with a semicolon ";". </simpara> <para> For example, to declare a such rule : <programlisting role="css"> p { padding: 5px; margin: 1px; } </programlisting> Or, with whitespace added to aid readability : <programlisting role="css"> p { padding: 5px; margin: 1px; } </programlisting> </para> <para> Here is the php code to create the same sentence with HTML_CSS : <programlisting role="php"> <![CDATA[ <?php require_once 'HTML/CSS.php'; $css = new HTML_CSS(); $css->setStyle('p', 'padding', '5px'); $css->setStyle('p', 'margin', '1px'); $css->display(); ?> ]]> </programlisting> </para> <para> Notice that we use twice <methodname>HTML_CSS::setStyle()</methodname> method call to declare each declaration block for the same selector. </para> </refsection> <refsection xml:id="package.html.html-css.intro.concepts.selectors-group"> <info><title>Grouping selectors</title></info> <simpara> When several selectors share the same declarations, they may be grouped together to save writing the same rule more than once. Each selector must be separated by a comma. For example : </simpara> <para> <programlisting role="css"> h1, h2, h3, h4 { padding: 1em; }..highlight p, .highlight ul { margin-left: .5em; } #main p, #main ul { padding-top: 1em; } </programlisting> </para> <para> To produce such result, we will need help of 3 new methods : <methodname>HTML_CSS::setSameStyle()</methodname>, <methodname>HTML_CSS::createGroup()</methodname> and <methodname>HTML_CSS::setGroupStyle()</methodname>. </para> <para> <programlisting role="php"> <![CDATA[ <?php require_once 'HTML/CSS.php'; $css = new HTML_CSS(); // two selector groups only $css->setStyle('.highlight p', 'margin-left', '.5em'); $css->setSameStyle('.highlight ul', '.highlight p'); // or even this way $g2 = $css->createGroup('#main p, #main ul'); $css->setGroupStyle($g2, 'padding-top', '2em'); // more than two selector groups $g1 = $css->createGroup('h1, h2, h3, h4'); $css->setGroupStyle($g1, 'padding', '1em'); $css->display(); ?> ]]> </programlisting> </para> <para> We should take care than grouping two selectors may be write either with <methodname>HTML_CSS::setSameStyle()</methodname> or with couple <methodname>HTML_CSS::createGroup()</methodname> and <methodname>HTML_CSS::setGroupStyle()</methodname>. When we have to group three or more selectors, there is only one possibility: couple <methodname>HTML_CSS::createGroup()</methodname> and <methodname>HTML_CSS::setGroupStyle()</methodname>. </para> </refsection> <refsection xml:id="package.html.html-css.intro.concepts.comment"> <info><title>CSS comments</title></info> <simpara> You can insert comments in CSS to explain your code. Like HTML comments, CSS comments will be ignored by the browser. A CSS comment begins with "/*", and ends with "*/". Comments can appear before or within rule sets as well as across multiple lines. </simpara> <para> HTML_CSS 1.0.0 has not yet ability to handle comment such as : </para> <para> <programlisting role="css"> /* Comment here */ p { margin: 1em; /* Comment here */ padding: 2em; /* color: white; */ background-color: blue; } /* multi-line comment here */ </programlisting> </para> <para> <warning> <para> The common mistake that people make when writing comments is to expect getting all comments describe with such code below : it's an error. </para> </warning> </para> <para> <programlisting role="php"> <![CDATA[ $css->setComment('comment here'); $css->setStyle('p', 'margin', '1em'); $css->setStyle('p', 'padding', '2em'); $css->setComment('color: white;'); $css->setStyle('p', 'background-color', 'blue'); $css->setComment(' multi-line comment here '); ]]> </programlisting> </para> <para> You will only get such result: <programlisting role="css"> /* multi-line comment here */ p { margin: 1em; padding: 2em; background-color: blue; } </programlisting> </para> <para> Only one comment is allowed due to usage of parent class method <methodname>HTML_Common::setComment()</methodname>. </para> </refsection> </refsection> </refentry>
« previous php.pear.doc (#11458) next »