Posted By

ramnath on 08/17/09


Tagged

css attribute selectors


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


Using CSS 2 and 3 Selectors


 / Published in: CSS
 

URL: http://reference.sitepoint.com/css/attributeselector

CSS 2 and 3 Selectors

  1. CSS2 Attribute Selectors
  2. ---
  3. a[href]{
  4. declarations
  5. }
  6.  
  7.  
  8. a[href="index.html"] {
  9. declarations
  10. }
  11.  
  12. /* for matching hyphen separated values starting with "en" eg: "en-US"*/
  13. tag[hreflang|="en"] {
  14. declarations
  15. }
  16.  
  17. /* for matching space separated values containing "myClass"
  18. eg: class=" bold myClass red" */
  19. tag[class~="myClass"] {
  20. declarations
  21. }
  22.  
  23.  
  24. CSS3 Attribute Selectors
  25. ---
  26. /* for matching values starting with... */
  27. a[href^="http:"] {
  28. declarations
  29. }
  30.  
  31. /* for matching values ending with... */
  32. img[src$=".png"] {
  33. declarations
  34. }
  35.  
  36. /* for matching values containing... */
  37. a[href*="yahoo"] {
  38. declarations
  39. }

Report this snippet  

You need to login to post a comment.