Create Social Media Icons Using Font-Awesome and CSS

Font Awesome is a, well, awesome tool that gives developers free access to hundreds of different useful icons to add to their sites and web apps. It’s becoming a really nice alternative to downloading PSD icon sets, largely because since the icons are HTML elements, they can be completely manipulated (color, size, positioning) using CSS. They’re much more dynamic than .jpegs and .pngs.

Font Awesome has icons for every occasion, but the ones I find myself using most often are the ones that correspond to different social media platforms. Making those popular social media button icons is SO easy using Font Awesome and CSS — no photoshop required.

Join us in our newest publication:

To start using Font Awesome, make sure you’ve got their library loaded either on your server or by lining to the Font Awesome CDN either in the head of your HTML or at the top of your stylesheets using @import, like this:

  1. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

For the purposes of this tutorial, let’s use one of the more popular social media sites as our example: Facebook. Font Awesome has a few different Facebook icons that you an utilize (check out all their icons here).

To add the icon to your site, you’ll need to place the following HTML code wherever you’d like the Facebook icon to show up on your page(s).

<i class="fa fa-facebook" aria-hidden="true"></i>

Each Font Awesome Icon has its own corresponding class, which you can look up on its individual page on Font Awesome’s site. Here’s what the Facebook icon looks like before we apply any styling to it:

Screen Shot 2016-06-28 at 9.32.20 AM

Let’s add some CSS:

  1. i.fa.fa-facebook{
  2. border-radius: 100%;
  3. font-size: 28px;
  4. height: 38px;
  5. line-height: 40px;
  6. margin: 5px;
  7. text-align: center;
  8. width: 38px;
  9. border: 1px solid #3B5998;
  10. color: #3B5998;
  11. }

Screen Shot 2016-06-28 at 9.40.37 AM

Because the icon is an HTML element, it responds to styling just like any other HTML element, so using CSS, we can apply the signature Facebook blue, we can add a border-radius to make the element round and add a nice, clean border as well. We can play around with the margins, the size of the element, and the size of the icon (which can be adjusted using font-size). We can even add some hover styles and CSS transitions much more easily than if we were working with an image rather than an HTML element. Using icons like these over images makes it a lot easier for developers to get creative using CSS.

Share and Enjoy !

0Shares
0 0