How to automatically add pdf icon to pdf links

Adding a pdf icon to the PDF link can be easily done by  CSS.  Using the css you can only add the pdf icon to the pdf links. The following css identifies the .pdf extension from the anchor tag and adds the background property only to the pdf links.

<style>
a[href$=".pdf"] {
background: url("pdf_icon_image.png") no-repeat scroll 0 0 / 45% auto rgba(0, 0, 0, 0);
padding-left: 20px;
}
</style>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s