Get access to an awe-inspiring collection Of 87 Beautiful Wordpress themes for the price of one Get it now Ad

Lightweight social share icons

Published: 11.10.2016 | Last update: 22.2.2019

The problem with Facebook's and similar JavaScript share buttons or with services like SumoMe is that they add many additional HTTP requests and can slow down your site quite significantly.

In today's tutorial, I would like to show you how to create a set of working and lightweight social share icons for your website. I will teach you how to create nice looking modern icons and how to add the necessary functionality to make them work without decreasing your site's performance with many additional requests.

Before we begin, you can have a look at the demo to see the result of the tutorial and download the source files.

Demo Download files

HTML template

As usual, we will start with the main HTML template file. You can call it, as you like, I have just named it index.html in this example.

As the template will serve just as an example article, there is not much to explain.

Things you should not forget to include are custom.css and custom.js files, which we will use to define the sharing icons' look and behaviour.

For the social networks' logos, we will be using an icon font called Socicons and we will include a link to its stylesheet on myfontastic CDN too. The reason I chose this icon set is that it is up to date and contains a really wide choice of icons. I wanted to use FontAwesome at first but it does not contain, for an unknown reason, an icon for Buffer.

For the demo purposes, I included Bootstrap CSS and JS and also a Roboto web font and some dummy text too.

        <title>Share Icons Tutorial by</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="" rel="stylesheet">
        <link href=',400,700,900' rel='stylesheet' type='text/css'>

        <link href="" rel="stylesheet">
        <link href='custom.css' rel='stylesheet' type='text/css'>
        <meta property="og:title" content="Share Icons Tutorial by">
        <meta property="og:site_name" content="Bootstrapious">
        <meta property="og:image" content="template-homepage.png">    
        <meta property="og:description" content="This is a demo for our tutorial showing you how to nice custom share icons to your website.">    

        <meta name="twitter:card" content="summary">
        <meta name="twitter:creator" content="@bootstrapious">

        <div class="container">
            <div class="row">
                <div class="col-lg-8 col-lg-offset-2">
                    <h1>Share Icons Tutorial by <a href=""></a></h1>
                    <p class="lead">This is a demo for our tutorial showing you <strong>how to create nice custom share icons</strong> for your website.</p>
                    <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
                    <p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>

        <script src=""></script>
        <script src=""></script>
        <script src="custom.js"></script>

Icons - HTML

Now, we can proceed to the HTML code of our sharing icons.

We work with a <p class="social">, in which we will place the links to each of the sharing services.

The link itself includes an <i> icon and also a span element <span class="sr-only"> what will be shown the users using a screen reader.

We will place <p class="social"> behind the last paragraph in our template. The list of the available icons from the Socicons set can be found here.

As you can see, the format and the number of parameters that you need to pass to the social network's URL varies and I will describe some of them further in the article. Also, the classes of the links (e.g. class="facebook") will serve us in the next parts of this tutorial.

When using this code on your site do not forget the replace the URLs and other parameters with your own. If you will use it on a small website, you can edit it manually, otherwise, it would be a good idea to have e.g. PHP replace it for you.

<p class="social">
    <a href="" class="facebook">
        <i class="socicon-facebook"></i><span class="sr-only">Share on Facebook</span>
    <a href="" class="gplus">
        <i class="socicon-googleplus"></i><span class="sr-only">Share on G+</span>
    <a href=";;via=bootstrapious" class="twitter">
        <i class="socicon-twitter"></i><span class="sr-only">Share on Twitter</span>
    <a href=";;summary=Check%20out%20this%20nice%20tutorial&amp;" class="linkedin">
        <i class="socicon-linkedin"></i><span class="sr-only">Share on LinkedIn</span>
    <a href=";" class="buffer">
        <i class="socicon-buffer"></i><span class="sr-only">Save to Buffer</span>
    <a href="" class="pocket">
        <i class="socicon-pocket"></i><span class="sr-only">Save to pocket</span>

Icons - CSS

So, let's have a look at the CSS stylesheet for share icons and let's give them a nice and decent look. The stylesheet should be named custom.css, save it to the same folder as the template.

If you will be using the code on a page using the Bootstrap framework, you can omit the first definition for the .sr-only element, as it is also part of the Bootstrap's CSS. 

The code is quite self-explanatory, I think, so I will just briefly describe the result:

I formatted the a links as round inline blocks with 3em width and height.

When not hovering over the link, it will have a grey border, also the icon itself will be grey. When the user hovers over it, the border and text colour will change to dark blue.

You can easily modify the hover colour by simply replacing the occurrences of the darkblue colour in the code.

/* you can remove this if using with Bootstrap */
.sr-only {position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0;}

/* monochromatic share icons */ a {display: inline-block; margin: 0 10px 10px 0; color: #fff;  width: 3em; height: 3em; border-radius: 1.5em; line-height: 3em; font-size: 1.2em; vertical-align: bottom; text-align: center; border: solid 1px #ccc; color: #ccc; transition: all 0.2s ease-out;} a:hover, a:focus  {color: darkblue; border-color: darkblue; text-decoration: none;} a i {vertical-align: middle;} a i:before {line-height: 3em;}

Icons - JavaScript

We could work without Javascript completely, but we would have to open the links in the same or new tab of the browser. With this bit of JavaScript, when the user clicks on the share link, the link will nicely open itself in a small window with no scrollbars, toolbar, etc.   

$(function () {

    $('.social a').on('click', function (e) {

        e.preventDefault();$(this).attr('href'), 'shareWindow', 'height=450, width=600, top=' + ($(window).height() / 2 - 275) + ', left=' + ($(window).width() / 2 - 300) + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0');


The result

Icons - URLs and parameters

The links in our social icons will lead to their API scripts that will take care of the sharing itself. The number of the parameters differs, but most of them need the URL to be shared and you can add additional parameters to it to enhance the sharing experience for the user.

Important to mention is that all the parameters in the URL should be URL-encoded. If you will be using the icons on HTML only website, you can encode them manually with this tool, if you are using PHP, you can encode the parameters using urlencode() function in PHP.

Now, we will go quickly through all the services to have a look at what parameters they need:


<a href="" class="facebook">...</a>

Needed parameters:

  • u - URL-encoded URL to share


<a href="" class="gplus">...</a>

Needed parameters:

  • url - URL-encoded URL to share


<a href=";;via=bootstrapious" class="twitter">...</a>

Optional parameters:

  • url - URL-encoded URL to share
  • via - account handle to mention in the tweet as a source
  • text - URL-encoded text of the prefilled tweet


<a href=";;summary=Check%20out%20this%20nice%20tutorial&amp;" class="linkedin">...</a>

Needed parameters:

  • url - URL-encoded URL to share
  • mini - must be set to true


Optional parameters:

  • summary - URL-encoded summary text
  • source - your website main URL


<a href=";text=Check%20out%20this%20nice%20tutorial" class="buffer">...</a>

Needed parameters:

  • url - URL-encoded URL to share

Optional parameters:

  • Text- URL-encoded summary text


<a href="" class="pocket">...</a>

Needed parameters:

  • url - URL-encoded URL to save

Wrapping up

This could be easily the end of this tutorial. You should now have a working set of nice social share icons for your website that would not have any negative effects on your site's performance. 

As a bonus for you, I have prepared a second look for the icons - now with more colour. There won't be any big changes to the already written code, so let's have a look.

Add colours to the icons


We will make the changes mostly via the stylesheet, so all we need to do in our HTML file is to add class="social-colour" to our <p class="social">.

<p class="social social-colour">...</p>


To colour our icons, we will use their classes that we added in one of the first steps. To each of the classes, we will apply a colour for its background and border based on the service's brand colour, i.e. a blue background and border for the Facebook icon, a red one for G+, etc.

/* coloured share icons */ a {color: #fff;} a:hover, a:focus {color: #fff;} a.facebook, a.facebook:hover, a.facebook:focus {background-color: #4460ae; border-color: #4460ae;} a.gplus, a.gplus:hover, a.gplus:focus {background-color: #c21f25; border-color: #c21f25;} a.twitter, a.twitter:hover, a.twitter:focus {background-color: #3cf; border-color: #3cf;} a.instagram, a.instagram:hover, a.instagram:focus {background-color: #cd4378; border-color: #cd4378;} a.buffer, a.buffer:hover, a.buffer:focus {background-color: #000; border-color: #000;} a.pocket, a.pocket:hover, a.pocket:focus {background-color: #f04056; border-color: #f04056;} a.linkedin, a.linkedin:hover, a.linkedin:focus {background-color: #0373b4; border-color: #0373b4;}

The result

The result of these few little tweaks in the stylesheet should like pictured below.  


I hoped this little tutorial has helped you and you will use it on the web soon.

Which colour version did you like - the monochromatic one or the coloured one? Did I miss some of the important social networks? Let me know in the comments below.

Where to go next?

To learn more similar stuff, check out the collection of my Bootstrap tutorials.

Hi, I'm Ondrej, creator of Bootstrapious. I have published Bootstrap tutorials and freebies here since 2015.

Thanks for stopping by and have a great day ;)

Ondrej, Bootstrapious

You might also like one of my Free Templates

Italiano - Restaurant or Café Template

Italiano is my free Bootstrap 4 HTML responsive template. You can use it to build an elegant…

View template

Foliou - Bootstrap Portfolio

Foliou - Bootstrap Portfolio

Foliou is a responsive one-page Bootstrap 4 portfolio template. It presents your work in a…

View template

Bootstrap Blog

Bootstrap Blog is a free Bootstrap 4 blog template. Minimalistic design, mostly grayscale elements. Included are 3 HTML page templates - Homepage, Category page and Blog post. Seven colour variants.

More than 10,000 users trusted this template.

View template

Share on Facebook Share on Twitter Share on LinkedIn