--> Add Icons Next To Hyperlinks Using CSS3 | Experience Lab - Online business creation and development guide for bloggers and startups

Add Icons Next To Hyperlinks Using CSS3

Cascading Style Sheet is the heart of designers and with latest web technology such as CSS3, designing has become even more interesting. Tha...

Hyperlink-IconsCascading Style Sheet is the heart of designers and with latest web technology such as CSS3, designing has become even more interesting. Thanks to CSS3 attribute value selectors, now you can style any file extension or tag.

I am using CSS3 attribute selector property in this tutorial to add Icons to hyperlinks. Previously we had to use JavaScript to add an icon next to the hyperlink on your blogger blog or website but now you can do it easily using CSS3. The icon will depend upon the type of file extension. If your link is pointing to a mp3 file then it will add a music symbol next to the link and so on. See the demo which shows 13 file format links,

Live Demo


How To Add Icons to Hyperlinks in Blogger?

  1. Go To Blogger > Design>  Edit HTML
  2. Check the "Expand Widget Templates" Box
  3. Search for this,

]]></b:skin>

     4.  Just above it paste the code given below,

/*--------- MBT Hyperlink Icons ----------*/

a[href*='.js'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2cxgoUXDoBrJn7mjRfA-s44IC8WR0JfvT8bgllbj7eTSrvKYwirqTb9Q2ExWIoV49mZddUFCsZaF_-y9-JkDY3_IW0P54ASAFZClbCB4kfxhyphenhyphenEHfze4WdScxDR6-SmI5rsCEP4fdCRjM/s400/file_js.png) no-repeat 0 0;
padding:7px 0 0 25px;
}

a[href*='.gif'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs6tfQZEx89Iy3U3KAJakJeWcoiVEfYT0WHCXhIRQji1nJNbp_1HtiZfKP9Y7Dd8324M9UWQ_9dJZG2wpuTZdKQlg2cCboBByWBoqztihY_lW325DDG2q6RxIwK08LrJ_ChaHbKEodQms/s400/file_gif.png) no-repeat 0 0;
padding:7px 0 0 25px;
}

a[href*='.doc'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfD5jaXOiIIBxph9GoVwmaFmqsLgbCJhXLHONf0WUlQm-f6uNbhDo23k_t9CQvgPiHKvVWFVRBY2CctoD9RXmWu4ADj4kkZ0PhhCVDhAduP4RNiBPexl0I0zO5QoQo20hhs6aTmHuZnss/s400/file_doc.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}

a[href*='.rar'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigfJHd-gEcS0YVd3QSzx_YdKGoppT93ObFvWTMmOnnTcVFD6A5ZTot5efi7DgBDWxz9nsB2DNxhKsfdsiKdeqJZ5wk01-doEgqOYtwd4P2UF_WOu0esazwRXa8k2639O2oTt8eOBMoCvs/s400/file_rar.png) no-repeat 0px 0px;padding:7px 0 0 25px;
}

a[href*='.zip'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMbq9KfNBgZ5ZnCDpn1nf3B1wohchGBA3Pe8JpEUQcxwA-QcuXdfIL5PyX5tW55xWtpPhTfAFVSxYomAne_12W5xwz1J1D-V2e9r1DuvmxmRVrD6D7LpYVPSm8Pa6RcO-9_wERefTAAEs/s400/file_zip.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}

a[href*='.mp4'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRxFPjsbdaY767oC9FxGV7YQ-bjR5ZZcFORIfsU5efa80aKNEcklwJZHZDv4uWGAz-3-OwzShrkrGCM6h_go5k9U11hU09HkO-Ax0ofRGgjHWmmdD4kK50WxUJ3mTguy1gBVCzZg12w4E/s400/file_mp4.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}

a[href*='.php'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxYUkStbYJX22mFl1uwmteuwRvVnwRvLih92PoYrfn9vrcjElRZol8NyQu5JbuZrKU7ieJcDikLwRkLuSjUOQXeyKuNu7F876HRsxPg_VpjfMgGtVOoSHZ_bEj34Ly1Bv482w-FA742Y0/s400/file_php.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}


a[href*='.xml'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGmX_FCShzSZjUeBS00fs7x2H1f9J0GpEMneSzLpCLPPe45vKyAvYCHH2C4tOicaVYx7jGsbpTi5OKsA7jfOWXrGFFSfDZAelqhGC4-zGHz0vYscYtifgRdUZR1uv1DH2Wmp1l0Fj84Sc/s400/file_xml.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}

a[href*='.pdf'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2mPvKFNe0rHuK9dA3lMy6roiSvg_hMAOI6bSrvbE6AMVHwFsTePBrYel1SkOT5NxHyuZciL7tMVlQVVEiVKdBkWi8vV0wDg6IlOAgilwMRl8iyKKl4M0TPpLGPk5_f0UoDkStm2ycSFw/s400/file_pdf.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}

a[href*='.xls'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjn2lBNxYKs7cseE4qxFr4f23QAUhLgjvzkBBvQDw6XoBYGrs7enEc2lFFs8OsdKmENpj2w2roKQGOA0n6IUMsyROT4y8wdiIEeNiihQolbn7mEtQO_TEGfjj1gdqORVUbJ5fSeTljQM4/s400/file_xls.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}


a[href*='.mpg'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMh-zHJVUkMKSBjwDwzYNpM6tqljdcXBypQdyZBy2b-ZuSSkW4q1ecelyeDrihR9X7F7lX6CR-NaWEyy63pfLnUY6D3uk1oENlp3dHy5uRh-OKKp-FebsArKgeaXvN6VsJKYtymXuwvBA/s400/file_mpg.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}


a[href*='.bmp'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh23q0E-uvXSf97_4pAGB4l3YvibAvqcaPMkAN4rIQJpUQEgZ9sq9QEIf0o4l0MnUfeB5llS3D1cV3MV7FnYVetzaBM5CqMtPsVsp3tWx2Z8be4xue15pIOwLwo64P7V_yXeCnfioQne8c/s400/file_bmp.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}


a[href*='.avi'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL3-ex5gBLcQCZGFvDszO29-dCmu_sjc2RbDbNkAWeq5HNuVVXGJ2KNhpJaEJuSyOlHMuBeDVWMHr7Vng_8aZ3mMQyqjYx-OHBJhVKle2ZDxY39-4lFiVXMxkM0gFLxhXoMNrjb1eWRM8/s400/file_avi.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}


a[href*='.mp3'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQmRI1Fl8MkW9Z17CUy0YzJd26NfhfUaEs9qb8Snl2EHNfk1g5i6sI1heCkKyG_MvCXNf34xHH8qLDD-Pbkoicb5XXPZmFnnX4cEoQz48mQ6jnQ3039OUPB3nEqOl6NteZV4TaMI5FrqU/s400/audio_alt.png) no-repeat 0px 0px;
padding:7px 0 0 25px;
}

a[href*='mailto'] {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt0tuiMPFdFC4Bdx-lB3wlOAf3GdCkifso9icK6HuGNmNzDBMh7o4ZFkgEbpCbjlpjimmFG8vakOQ142lsSnnlptGIYq6vqmwy0Yfc3KDc2s997nvtdnKHl-ZiX0sbDtOTjXCFGo506KA/s400/e_mail.png) no-repeat 0px 0px;
padding:0 0 0 25px;
}

 

    4.   Save your templates and you are done!

 

How it works?

The icons appear when the file extension is detected in the link. For Example if I add a link to pdf file like this,

<a href="http://www.mybloggertricks.com/xyz.pdf">Download E-book</a>

Then the link will appear like this when I publish it,

hyperlink-image

Now add any Ebook or any image link in your blogger posts, sidebars or footer anywhere you want and you will find cute icons appearing next to the link. You can also use icons of your choice by simply changing the icon image links  in the code above. The code is really easy to edit and I hope after having read so much of our tutorials you can at least edit this code. Have fun and let me know if you faced any problem. Enjoy! :)

PS: This technique is first bloggerized at MBT, any adoption of the code without attribution to MBT author will be taken as copyright violation.

COMMENTS

Name

Affiliate Marketing,12,Announcement,34,Bing,9,Bitcoin,38,blog,7,Blogger Resources,42,Blogger Templates,4,blogger tricks,156,Blogging ethics,70,Blogging tips,198,Bugs and Errors,34,Business,11,Copyright Violation,9,CSS and HTMLTricks,95,Designs,8,drop down menu,7,eBook,12,Email Marketing,7,Events,30,Facebook,30,Facebook tricks,49,Google,157,Google AdSense,42,Google Analytics,7,Google Plus,51,Google Plus Tricks,38,Guest Posts,112,home,2,How To,77,Internet,1,JSON Feeds,25,Kitchen Recipes,2,Label Based Sitemap Themes,1,Make Money Online,108,Marketing,17,MBT Blogger Templates,7,Menus,1,News,146,Pages,1,Posts,10,presentations,15,Responsive,10,Reviews,7,SEO,307,Settings,6,Shortcode,15,Sitemap Themes,1,Social Media,155,Technology,7,Templates,1,Tips,2,Tools,1,Traffic Tips,80,Video,19,Web Designing,62,web hosting,18,Webmaster Tools,97,Widgets,199,wordpress,26,
ltr
item
Experience Lab - Online business creation and development guide for bloggers and startups: Add Icons Next To Hyperlinks Using CSS3
Add Icons Next To Hyperlinks Using CSS3
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigxpdsQjKjUE8qNeXjWXrCt6WQFjxGFD8jzkDt1L9Bj29dpQXpMfQXN1YmaLbytu3UGDtv9af7ijy7nrBFYmPvxZ9HagyX_UU2NgyvpyyGhwU6MZBA2jfZ-F3P6xaRqj42Rmqol3BW5_c/?imgmax=800
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigxpdsQjKjUE8qNeXjWXrCt6WQFjxGFD8jzkDt1L9Bj29dpQXpMfQXN1YmaLbytu3UGDtv9af7ijy7nrBFYmPvxZ9HagyX_UU2NgyvpyyGhwU6MZBA2jfZ-F3P6xaRqj42Rmqol3BW5_c/s72-c/?imgmax=800
Experience Lab - Online business creation and development guide for bloggers and startups
https://www.experiencelab.info/2011/06/add-icons-next-to-hyperlinks-using-css3.html
https://www.experiencelab.info/
https://www.experiencelab.info/
https://www.experiencelab.info/2011/06/add-icons-next-to-hyperlinks-using-css3.html
true
2959477579779989044
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share. STEP 2: Click the link you shared to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy