Posted By

vaughanj on 06/08/14


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

kwkistler


Style links by file type


 / Published in: CSS
 

URL: http://css-tricks.com/attribute-selectors/

A good use case for these is labeling file download anchor links with icons based on what type of file they are. For example, PDF's get a PDF icon and Word Documents get a Word icon:

  1. a[href$=".pdf"] { background: url(icon-pdf.png) left center no-repeat; padding-left: 30px; }
  2. a[href$=".doc"] { background: url(icon-doc.png) left center no-repeat; padding-left: 30px; }

Report this snippet  

You need to login to post a comment.