I was wondering how hard it is to make a class for downloads that places an icon right before the text and both text and icon are part of the link to the attached file. Is there a simple way to do this with CSS?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming that all links to downloads are
aelements, of class-name ‘downloadLink’:If those links are of the format:
Then the css:
Will give specific backgrounds to links with a
hrefattribute that ends withpdforpng. This approach is based around CSS3’s attribute-selectors, which might reduce cross-browser compatibility but, according to Quirksmode’s compatibility table not by much (basically everything above, and including, IE7 should support this (albeit it doesn’t specify which of the selectors are supported) in IE or other browsers).References:
$=selector.