summaryrefslogtreecommitdiff
path: root/pocketCSS.html
blob: 980809545d56ef6df731159f43d086dabda6da36 (plain)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>pocket wiki - Terminal commands</title>
  7. <meta name="author" content="Natalie Downe">
  8. <!-- Date: 2009-05-23 -->
  9. <link rel="stylesheet" href="css/main.css" type="text/css">
  10. <link rel="stylesheet" href="css/print.css" type="text/css" media="print">
  11. <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
  12. <script type="text/javascript" src="js/dynamic.js"></script>
  13. </head>
  14. <body>
  15. <div id="book">
  16. <div id="page1" class="page">
  17. <div class="inner">
  18. <h1><span>dinky pocket book</span>CSS Selectors</h1>
  19. <div class="footer">
  20. <p>This book belongs to:</p><br><br>
  21. <hr>
  22. </div>
  23. </div>
  24. </div>
  25. <div id="page2" class="page">
  26. <div class="inner">
  27. <h2>Simple selectors</h2>
  28. <p class="micro">assume throughout that <code>E</code> and <code>F</code> are elements, they can have attribute <code>foo</code> e.g. <code style="white-space: nowrap">&lt;e foo="bar"&gt;</code> you can replace these with any elements or attributes.</p>
  29. <p class="micro">In HTML, elements in CSS can be uppercase like these examples. In XHTML, elements must be lower case. Classes and IDs are <strong>always</strong> case sensitive</p>
  30. <p><span class="micro"><strong>universal selector</strong>, match any element</span>
  31. <code>*</code>
  32. </p>
  33. <p><span class="micro"><strong>type</strong> (or element) selector</span>
  34. <code>E</code>
  35. </p>
  36. <p><span class="micro"><strong>ID selector</strong> an E element with ID equal to "myid", e.g. <code>&lt;e id="myid"&gt;</code></span>
  37. <code>E#myid</code>
  38. </p>
  39. <p><span class="micro"><strong>class selector</strong> an E element whose class is "myclass", e.g. <code>&lt;e class="myclass"&gt;</code></span>
  40. <code>E.myclass</code>
  41. </p>
  42. </div>
  43. </div>
  44. <div id="page3" class="page">
  45. <div class="inner">
  46. <h2>Combinators <abbr class="amp" title="and">&amp;</abbr> negation</h2>
  47. <p><span class="micro"><strong>descendant combinator</strong> to style an F element, which is a descendant of an E element</span>
  48. <code>E F</code>
  49. </p>
  50. <p><span class="micro"><strong>child combinator</strong> an F element which is the direct child of an E element</span>
  51. <code>E > F</code>
  52. </p>
  53. <p><span class="micro"><strong>adjacent sibling combinator</strong> an F element that is immediately preceded by an E element</span>
  54. <code>E + F</code>
  55. </p>
  56. <p><span class="micro"><strong>general sibling combinator</strong> an F element preceded at some point by an E element</span>
  57. <code>E ~ F</code>
  58. </p>
  59. <p><span class="micro"><strong>negation pseudo-class</strong> an E element that does not match simple selector <code>s</code></span>
  60. <code>E:not(s)</code>
  61. </p>
  62. </div>
  63. </div>
  64. <div id="page4" class="page">
  65. <div class="inner">
  66. <h2>Attribute selectors</h2>
  67. <p><span class="micro">element E with a "foo" attribute</span>
  68. <code>E[foo]</code>
  69. </p>
  70. <p><span class="micro">E&#8217;s attribute <code>foo</code>, value exactly equal to <code>bar</code></span>
  71. <code>E[foo="bar"]</code>
  72. </p>
  73. <p><span class="micro">E&#8217;s attribute <code>foo</code>, value is whitespace-separated values, one of which is exactly "bar"</span>
  74. <code>E[foo~="bar"]</code>
  75. </p>
  76. <p><span class="micro">E&#8217;s attribute <code>foo</code>, value begins exactly "bar"</span>
  77. <code>E[foo^="bar"]</code>
  78. </p>
  79. <p><span class="micro">E&#8217;s attribute <code>foo</code>, value ends exactly "bar"</span>
  80. <code>E[foo$="bar"]</code>
  81. </p>
  82. <p><span class="micro">E&#8217;s attribute <code>foo</code>, value contains substring "bar"</span>
  83. <code>E[foo*="bar"]</code>
  84. </p>
  85. <p><span class="micro">E&#8217;s attribute <code>foo</code> has a hyphen-separated list of values beginning (from the left) with "en"</span>
  86. <code>E[foo|="en"]</code>
  87. </p>
  88. </div>
  89. </div>
  90. <div id="page5" class="page">
  91. <div class="inner">
  92. <h2>Structural pseudo-classes</h2>
  93. <p class="micro"><code>n</code> can be replaced with an expression in all following cases <code>n</code> can be (odd), (even) or expressions such as (3n + 1)</span></p>
  94. <p><span class="micro">an E element, the n-th child of its parent</p>
  95. <code>E:nth-child(n)</code>
  96. </p>
  97. <p><span class="micro">an E element, the n-th child of its parent, counting from the last one</span>
  98. <code>E:nth-last-child(n)</code>
  99. </p>
  100. <p><span class="micro">an E element, the n-th sibling of its type</span>
  101. <code>E:nth-of-type(n)</code>
  102. </p>
  103. <p><span class="micro">an E element, the n-th sibling of its type, counting from the last one</span>
  104. <code>E:nth-last-of-type(n)</code>
  105. </p>
  106. <p><span class="micro">an E element that is the document root, i.e. html</span>
  107. <code>E:root</code>
  108. </p>
  109. </div>
  110. </div>
  111. <div id="page6" class="page">
  112. <div class="inner">
  113. <h2>Structural pseudo-classes</h2>
  114. <p><span class="micro">an E element, first child of its parent</span>
  115. <code>E:first-child</code>
  116. </p>
  117. <p><span class="micro">an E element, first sibling of its type</span>
  118. <code>E:first-of-type</code>
  119. </p>
  120. <p><span class="micro">an E element, last child of its parent</span>
  121. <code>E:last-child </code>
  122. </p>
  123. <p><span class="micro">an E element, last sibling of its type</span>
  124. <code>E:last-of-type</code>
  125. </p>
  126. <p><span class="micro">an E element, only child of its parent</span>
  127. <code>E:only-child</code>
  128. </p>
  129. <p><span class="micro">an E element, only sibling of its type</span>
  130. <code>E:only-of-type</code>
  131. </p>
  132. <p><span class="micro">an E element that has no children (including text nodes)</span>
  133. <code>E:empty</code>
  134. </p>
  135. </div>
  136. </div>
  137. <div id="page7" class="page">
  138. <div class="inner">
  139. <h2>Pseudo-classes</h2>
  140. <p><span class="micro">matches a link E when E is a link and not visited, hovered over focused on or active</span>
  141. <code>E:link</code>
  142. </p>
  143. <p><span class="micro">the href target of the link E has been visited</span>
  144. <code>E:visited</code>
  145. </p>
  146. <p><span class="micro">the link E has been activated</span>
  147. <code>E:active</code>
  148. </p>
  149. <p><span class="micro">any element E when hovered over with a mouse</span>
  150. <code>E:hover</code>
  151. </p>
  152. <p><span class="micro">the link or form control E when tabbed to with a keyboard</span>
  153. <code>E:focus</code>
  154. </p>
  155. <p><span class="micro">element E is the fragment in the referring URI</span>
  156. <code>E:target</code>
  157. </p>
  158. <p><span class="micro">an element of type E in language "fr"</span>
  159. <code>E:lang(fr)</code>
  160. </p>
  161. </div>
  162. </div>
  163. <div id="page8" class="page">
  164. <div class="inner">
  165. <h2>Forms <abbr class="amp" title="and">&amp;</abbr> <span style="white-space: nowrap">Pseudo-elements</span></h2>
  166. <p><span class="micro">a user interface element E which is enabled</span>
  167. <code>E:enabled</code>
  168. </p>
  169. <p><span class="micro">a user interface element E which is disabled </span>
  170. <code>E:disabled</code>
  171. </p>
  172. <p><span class="micro">a user interface element E which is checked</span>
  173. <code>E:checked</code>
  174. </p>
  175. <p><span class="micro">the first formatted line of an E element</span>
  176. <code>E::first-line</code>
  177. </p>
  178. <p><span class="micro">the first formatted letter of an E element</span>
  179. <code>E::first-letter</code>
  180. </p>
  181. <p><span class="micro">generated content before an E element</span>
  182. <code>E::before</code>
  183. </p>
  184. <p><span class="micro">generated content after an E element</span>
  185. <code>E::after</code>
  186. </p>
  187. <p class="micro" style="text-align: right; border-top: 1px solid #E0E0E0; margin-top: 3em"><span class="micro">http://www.w3.org/TR/css3-selectors/</span></p>
  188. </div>
  189. </div>
  190. </div>
  191. </body>
  192. </html>