New here? Then you may want to subscribe to my rss feed. :)

Copy paste list of CSS snippets

May 15th, 2007 | Posted in CSS, Development | 1 Comments

List of CSS snippets, in no particular order. Naturally, most if not all will not work in IE6. I plan to add this list as and when.

  1. /* Selects all p tags that are the children of div elements */
  2. div > p
  3.  
  4.  
  5. /* Selects the next immediate sibling to the first one */
  6. p + p {text-transform: uppercase;}
  7. <p>i am all lowercase</p>
  8. <p>i am all uppercase</p>
  9.  
  10.  
  11. /* Sets elements with non-standard attributes */
  12. p[makemered]{color:#ff0000;}
  13. <p makemered="">i am red</p>
  14.  
  15.  
  16. /* Attribute value matching */
  17. a[href^="http://"]:not([href*="nextbigleap.com"])::after{
  18.     content:"\2197";
  19. }
  20. <a href="http://www.nextbigleap.com">I wont display an external link arrow</a>
  21. <a href="http://www.google.com">I will display an external link arrow</a>
  22.  
  23.  
  24. a[href="#"]::after{content:"\2620";} /* Exact match eg # */
  25. <a href="#">I will display skull and crossbones</a>

One Response to “Copy paste list of CSS snippets”

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>