Changes from Version 1 of documentation/RCSS/Syntax

Show
Ignore:
Author:
peterc (IP: 192.168.0.1)
Timestamp:
11/29/07 11:06:53 (10 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • documentation/RCSS/Syntax

    v0 v1  
     1[[PageOutline(1-5, Contents)]] 
     2= Syntax = 
     3 
     4A style sheet is made up of a number of rules. Each rule has a number of selectors, which define which elements the rule applies to, and properties, which are applied to those elements. 
     5 
     6The basic syntax of a rule is as follows: 
     7 
     8{{{ 
     9selector1, 
     10selector2, 
     11selector3 
     12{ 
     13    property1: value1; 
     14    property2: value2; 
     15    property3: value3; 
     16} 
     17}}} 
     18 
     19Selectors are comma-separated, followed by the rule block which is defined by curly braces. Inside the rule block is a list of semi-colon separated property declarations; each property declaration is made up of the property to set, a colon, and a space-separated list of the values to assign to that property. The values accepted by each value, and how many they require, is specific to each value. 
     20 
     21== Comments == 
     22 
     23Comments can be included in a style sheet using the C-style /* and */ characters. 
     24 
     25= Values = 
     26 
     27Which values each property accepts is given in their definition. Values may be keywords, which are set as specific strings such as ''auto'', ''left'', etc, or generic strings (such as font names or file paths), or one of the types described below. 
     28 
     29== Numbers == 
     30 
     31Specified as <number> in a property's ''Values'' list. A number can be an integer or real number. 
     32 
     33{{{ 
     34    font-size: 16; 
     35}}} 
     36 
     37== Lengths == 
     38 
     39Specified as <length> in a property's ''Values'' list. A length is a horizontal or vertical measurement consisting of a number and a unit. RCSS recognises the following units: 
     40 
     41 * '''px''': One px is equivalent to one pixel on the output medium. 
     42 * '''em''': One em is equivalent to the line-height of the current font. 
     43 * '''ex''': One ex is equivalent to the height of the current font's lower-case x. 
     44 
     45Note that as RCSS is designed solely for outputting to a computer monitor, it does not recognize the physical measurements '''in''', '''cm''', '''mm''', '''pt''' or '''pc'''. 
     46 
     47{{{ 
     48    width: 125px; 
     49}}} 
     50 
     51== Percentages == 
     52 
     53Specified as <percentage> in the property's ''Values'' list. A percentage value is evaluated relative to some other value, which is specified in each property that supports a percentage. For example, ''width'' can be expressed as a percentage, which is evaluated against the width of the element's containing block. 
     54 
     55{{{ 
     56    min-height: 50%; 
     57}}} 
     58 
     59== Colours == 
     60 
     61Specified as <colour> in the property's ''Values'' list. Colours represent a RGBA value, and can be declared in numerous ways: 
     62 
     63 * As the name of one of the 16 colours defined in the HTML 4.0 specification (aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow), plus grey (alias for gray), orange and transparent. 
     64 * Prefixed with the '#' character, followed by 3, 4, 6 or 8 hexadecimal digits. 3 or 6 digits represent an RGB triplet, and will have 255 attached as the opacity. If only 3 are specified, each digit will be replicated before being read; for example, #FE0 is equivalent to #FFEE00. 4 or 8 digits allow the specification of a translucent colour. 
     65 * In the format rgb(r, g, b) or rgba(r, g, b, a), where each of red, green, blue (and optionally alpha) is specified as a value from 0 to 255. An rgb value have an alpha of 255 attached. 
     66 * In the format rgb(r%, g%, b%) or rgba(r%, g%, b%, a%), where each of red, green, blue (and optionally alpha) is specified as a percentage value from 0 to 100. An rgb value will have full opacity. 
     67 
     68'''Important:''' Note that the declaration of the alpha channel when using the ''rgba'' keyword differs from the HTML5 specification. 
     69 
     70So, for example, the following colour declarations are identical: 
     71 
     72{{{ 
     73    color: red; 
     74    color: #F00; 
     75    color: #FF0000FF; 
     76    color: rgb(100%, 0%, 0%); 
     77    color: rgba(100%, 0%, 0%, 100%); 
     78    color: rgba(255, 0, 0); 
     79}}} 
     80 
     81= Referencing RCSS from RML = 
     82 
     83A style sheet can be either stored in an external file (usually with the extension .rcss) and referenced from an RML file, or declared inline inside an RML file. Referencing an external RCSS file is done using the <link> tag in the following manner: 
     84 
     85{{{ 
     86<html> 
     87    <head> 
     88        <link type="text/css" href="sample.rcss" /> 
     89 
     90    ... 
     91}}} 
     92 
     93File paths are relative to the referencing document. 
     94 
     95Declaring an inline style sheet is done using the <style> tag, also within the <head> tag: 
     96 
     97{{{ 
     98<html> 
     99    <head> 
     100        <style> 
     101            body 
     102            { 
     103                margin: 0px; 
     104            } 
     105        </style> 
     106 
     107    ... 
     108}}} 
     109 
     110Multiple style sheets can be included in a single document and combined with inline style declarations. The ordering of style declarations is important, as they may be used to resolve the precedence conflicting style sheet rules. 
     111 
     112Also, style sheet properties can be declared directly on an element. This is done by inserting semi-colon separated style sheet property declarations into the 'style' attribute of an element. For example, the following RML fragment: 
     113 
     114{{{ 
     115<div style="width: 25%; min-width: 55px;"> 
     116</div> 
     117}}} 
     118 
     119sets the 'width' property to '25%' and the 'min-width' property to '55px' on the 'div' element.