Changes between Initial Version and Version 1 of WF/Sintaxe


Ignore:
Timestamp:
07/24/07 15:01:37 (17 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WF/Sintaxe

    v1 v1  
     1{{{ 
     2 Any HTML element is a possible CSS1 selector. The selector is simply the element that is linked to a particular style. For example, the selector in 
     3 
     4 
     5 
     6P { text-indent: 3em } 
     7 
     8 
     9 
     10is P. 
     11 
     12Class Selectors 
     13 
     14 
     15 
     16A simple selector can have different classes, thus allowing the same element to have different styles. For example, an author may wish to display code in a different color depending on its language: 
     17 
     18 
     19 
     20code.html { color: #191970 } 
     21 
     22code.css  { color: #4b0082 } 
     23 
     24 
     25 
     26The above example has created two classes, css and html for use with HTML's CODE element. The CLASS attribute is used in HTML to indicate the class of an element, e.g., 
     27 
     28 
     29 
     30<P CLASS=warning>Only one class is allowed per selector. 
     31 
     32For example, code.html.proprietary is invalid.</p> 
     33 
     34 
     35 
     36Classes may also be declared without an associated element: 
     37 
     38 
     39 
     40.note { font-size: small } 
     41 
     42 
     43 
     44In this case, the note class may be used with any element. 
     45 
     46 
     47 
     48A good practice is to name classes according to their function rather than their appearance. The note class in the above example could have been named small, but this name would become meaningless if the author decided to change the style of the class so that it no longer had a small font size. 
     49 
     50ID Selectors 
     51 
     52 
     53 
     54ID selectors are individually assigned for the purpose of defining on a per-element basis. This selector type should only be used sparingly due to its inherent limitations. An ID selector is assigned by using the indicator "#" to precede a name. For example, an ID selector could be assigned as such: 
     55 
     56 
     57 
     581.svp94O { text-indent: 3em } 
     59 
     60 
     61 
     62This would be referenced in HTML by the ID attribute: 
     63 
     64 
     65 
     66<P ID=svp94O>Text indented 3em</P> 
     67 
     68 
     69 
     70Contextual Selectors 
     71 
     72 
     73 
     74Contextual selectors are merely strings of two or more simple selectors separated by white space. These selectors can be assigned normal properties and, due to the rules of cascading order, they will take precedence over simple selectors. For example, the contextual selector in 
     75 
     76 
     77 
     78P EM { background: yellow } 
     79 
     80 
     81 
     82is P EM. This rule says that emphasized text within a paragraph should have a yellow background; emphasized text in a heading would be unaffected. 
     83 
     84Declarations 
     85 
     86Properties 
     87 
     88 
     89 
     90A property is assigned to a selector in order to manipulate its style. Examples of properties include color, margin, and font. 
     91 
     92Values 
     93 
     94 
     95 
     96The declaration value is an assignment that a property receives. For example, the property color could receive the value red. 
     97 
     98Grouping 
     99 
     100 
     101 
     102In order to decrease repetitious statements within style sheets, grouping of selectors and declarations is allowed. For example, all of the headings in a document could be given identical declarations through a grouping: 
     103 
     104 
     105 
     106H1, H2, H3, H4, H5, H6 { 
     107 
     108  color: red; 
     109 
     110  font-family: sans-serif } 
     111 
     112 
     113 
     114Inheritance 
     115 
     116 
     117 
     118Virtually all selectors which are nested within selectors will inherit the property values assigned to the outer selector unless otherwise modified. For example, a color defined for the BODY will also be applied to text in a paragraph. 
     119 
     120 
     121 
     122There are some cases where the inner selector does not inherit the surrounding selector's values, but these should stand out logically. For example, the margin-top property is not inherited; intuitively, a paragraph would not have the same top margin as the document body. 
     123 
     124Comments 
     125 
     126 
     127 
     128Comments are denoted within style sheets with the same conventions that are used in C programming. A sample CSS1 comment would be in the format: 
     129 
     130 
     131 
     132/* COMMENTS CANNOT BE NESTED */ 
     133 
     134 
     135 
     136}}}