Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 0.90 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to add section numbers (1.2, 3.4.1) automatically using CSS?
  2. h1, h2, h3, h4 {
  3.   font-weight: normal;
  4. }
  5. h1 { font-size: 140%; }
  6. h2 { font-size: 120%; color:#049;}
  7. h3 { font-size: 110%; color:#06C;}
  8. h4 { font-size: 105%; color:#09C;}
  9.        
  10. ...
  11.  
  12. <h2>heading21</h2>
  13. ...
  14.  
  15. <h3>heading31</h3>
  16. ...
  17.  
  18. <h2>heading22</h2>
  19.        
  20. body {counter-reset:section;}
  21.     h1 {counter-reset:subsection;}
  22.     h1:before
  23.     {
  24.     counter-increment:section;
  25.     content:"Section " counter(section) ". ";
  26.         font-weight:bold;
  27.     }
  28.     h2:before
  29.     {
  30.     counter-increment:subsection;
  31.     content:counter(section) "." counter(subsection) " ";
  32.     }
  33.        
  34. <p><b>Note:</b> IE8 supports these properties only if a !DOCTYPE is specified.</p>
  35. <h1>HTML tutorials</h1>
  36. <h2>HTML Tutorial</h2>
  37. <h2>XHTML Tutorial</h2>
  38. <h2>CSS Tutorial</h2>
  39. <h1>Scripting tutorials</h1>
  40. <h2>JavaScript</h2>
  41. <h2>VBScript</h2>
  42. <h1>Heading </h1>
  43. <h2>One </h2>
  44. <h2>Two</h2>