Get our posts emailed to you with our monthly newsletter, subscribe here.

Looking back 5 or 10 years ago the process of designing website buttons was very tedious. CSS could handle a lot of the outer edges, but gradient backgrounds and icons required static images. And these newer design trends are still at the cusp of innovation. This means you will find plenty of modern websites still using images in place of CSS3 effects.

I want to focus this tutorial on the power of CSS3 icon fonts for designing user interfaces. We will be creating some generic CSS3 buttons with added icons for design aesthetics. However the icons will not be loaded from static images or sprite sheets. Instead we will be using the Entypo icons font for generating pictograms inside your website layout.

Live DemoDownload

Setting the Project Space

We should start out by putting together a working directory with all our files. I have created 2 documents index.html and styles.css. Also we need to download a copy of the Entypo fonts which you can get directly off their website. Windows users will get a .zip package while OS X users will have a DMG image file.

When it is all extracted you will find a series of folders with copies of the fonts. These are actually different versions to be used for very different purposes. Be sure that you are copying the files out of @font-face which are to be used on the web. The Desktop typeface is to be installed on your computer and the vector graphics would be useful in editors such as Adobe Photoshop.

I have copied all the font files into a new directory named font which we can access from the CSS codes. But first we should look into my HTML doc and see how to create the basic layout.

Building the Document

We are not including too many external libraries as they are not needed in this tutorial. However I am using the Google Webfont named Purple Purse for the heading text. Our document is coded using HTML5 doctype for greater support using new elements on the page.

<!doctype html>  <html lang="en-US">  <head>    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">    <title>CSS3 Buttons with Pictograms</title>    <meta name="author" content="Jake Rocheleau">    <link rel="shortcut icon" href="">    <link rel="icon" href="">    <link rel="stylesheet" type="text/css" media="all" href="styles.css">    <link rel="stylesheet" type="text/css" href="">    <script type="text/javascript" src=""></script>  </head>

Now the most important bit of code is related to the button syntax. I have setup a generic button class using the name .entypo but you can update this for your own site. We setup default grey buttons with opacity so the colors will show through the backgrounds. Let’s take a peek at some of the blue buttons on the page.

<button class="entypo blue"><span class="pictogram">&#59392;</span> Blue Archives</button>    <button class="entypo blue"><span class="pictogram">&#59148;</span> Tags</button>    <button class="entypo blue"><span class="pictogram">&#128077;</span> Likes This!</button>  

The icons themselves are encapsulated inside a span tag within the button text. We need to use some fancy maneuvering for the line-height and padding to get everything aligned properly. Keep this in mind when porting the icons over into bigger or smaller sizes. And if you want a reference guide for translating the icons check out this Entypo character map.

css3 entypo buttons character map icons

The map includes over 200 icons which you can use by adding the entity marker into HTML which uses the Entypo font family. I find that since we are using the same characters in code it helps search engines to identify the content(as opposed to using images).

Include Custom CSS Fonts

Although we are using the external Google webfont document this should not conflict with any local @font-face declarations. Let’s take a peek inside the stylesheet and see how I have this setup.

@font-face {      font-family: 'EntypoRegular';      src: url('font/entypo.eot');      src: url('font/entypo.eot?#iefix') format('embedded-opentype'),           url('font/entypo.woff') format('woff'),           url('font/entypo.ttf') format('truetype'),           url('font/entypo.svg#EntypoRegular') format('svg');      font-weight: normal;      font-style: normal;  }    @font-face {      font-family: 'EntypoSocial';      src: url('font/entypo-social.eot');      src: url('font/entypo-social.eot?#iefix') format('embedded-opentype'),           url('font/entypo-social.woff') format('woff'),           url('font/entypo-social.ttf') format('truetype'),           url('font/entypo-social.svg#EntypoRegular') format('svg');      font-weight: normal;      font-style: normal;  }

I have two distinct code blocks setup for the regular Entypo font along with the Entypo Social pack. This 2nd set will include icons for popular social media websites like Twitter, Github, Dribbble, and so forth. Also the kit includes all four of the base CSS3 typefaces which are EOT, TTF, WOFF, and SVG. It is rare to find an icon font which includes all the standard file types so we definitely want to support all the options.

After these blocks you will find a series of CSS resets which are necessary for defining the page structure. Then eventually we come down to the button styles which are using transparent backgrounds for design effects. This is a nice technique for building classes on your website which allows you to extend CSS functionality based on any color scheme.

button.entypo {    display: inline-block;    margin: 0;    margin-right: 12px;    cursor: pointer;    border: 1px solid #bbb;    overflow: visible;    color: #fff;    padding: 11px 25px;    font-size: 1.7em;    line-height: 1.55em;    vertical-align: middle;    text-decoration: none;    white-space: nowrap;    -webkit-border-radius: 4px;    -moz-border-radius: 4px;    border-radius: 4px;    -webkit-transition: all .15s linear;    -moz-transition: all .15s linear;    transition: all .15s linear;    text-shadow: 1px 0 0 rgba(0,0,0,0.35);    background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(255,255,255,0.3)), to(rgba(255,255,255,0)));    background-image: -webkit-linear-gradient(top, rgba(255,255,255,0.3), rgba(255,255,255,0));    background-image: -moz-linear-gradient(top, rgba(255,255,255,0.3), rgba(255,255,255,0));    background-image: -ms-linear-gradient(top, rgba(255,255,255,0.3), rgba(255,255,255,0));    background-image: -o-linear-gradient(top, rgba(255,255,255,0.3), rgba(255,255,255,0));    background-image: linear-gradient(top, rgba(255,255,255,0.3), rgba(255,255,255,0));  }  button.entypo:active {    box-shadow: 0 1px 1px rgba(0,0,0,0.35) inset;  }

Generating CSS3 Buttons

Keep in mind that many of these properties will only be supported by newer CSS3-compliant browsers. Older versions of Internet Explorer may struggle to render everything properly. But the secret to keeping our buttons transparent is to use rgba() syntax when defining colors for the gradient backgrounds.

This means the colors go from 0 opacity to 30% using #ffffff the whole time. It provides a background template for the colors to fill into and then generates a glossy effect. We can see the additional color classes and their hover/active states in the codes which follow.

/** Green Color Scheme **/ {    background-color: #57a957;    border-color: #57a957;  } {    background-color: #62c462;  } {    background: #57a957;  }      /** Blue Color Scheme **/ {    background-color: #269ce9;    border-color: #269ce9;  } {    background-color: #70b9e8;  } {    background-color: #269ce9;  }      /** Orange Color Scheme **/ {    background-color: #e9942e;    border-color: #d48a30;  } {    background-color: #ee9f40;  } {    background-color: #d48a30;  }      /** Pink Color Scheme **/ {    background-color: #ed4cd1;    border-color: #d22ec1;  } {    background-color: #ec69d5;  } {    background-color: #d22ec1;  }

The final magical piece to our stylesheet comes from implementing our new font family choices. Remember that each of the icon entities is encapsulated within a span using the classes .pictogram and .socialpictos. Each of these is referring to a different CSS3 font family which we defined at the top of our stylesheet.

/** Entypo Icons **/  .pictogram {    font-family: 'EntypoRegular';    float: left;    position: relative;    top: 0;    left: -9px;    font-size: 3.0em;    line-height: 0.5em;    font-weight: normal;    vertical-align: middle;   }    .socialpictos {    font-family: 'EntypoSocial';    float: left;    position: relative;    top: 0;    left: -9px;    font-size: 3.0em;    line-height: 0.5em;    font-weight: normal;    vertical-align: middle;  }

Notice how the icons are positioned relative and we need to push them away from the original text. This could be done using margins, but in some browsers the extra space doesn’t work correctly or the margins don’t appear at all. Middle vertical alignment and a line-height value of 0.5em allows the button to keep its original size while still centering our pictogram icons. These CSS3 button styles work brilliantly and may be copied over and over for duplicating results.

Live DemoDownload

Final Thoughts

Be sure and check out my live demo sample to catch a glimpse at what we are trying to build. The codes are not overly complex and most web developers should be able to follow along. Feel free to download a copy of my source code and edit this to fit your own needs. All of my original codes are released under public domain and can be modified for use on any projects.

The Entypo font package is wonderful and fits nicely within other open source resources for talented developers. If you have any additional thoughts or questions please share with us in the post discussion area below.

Posted by Jake Rocheleau

Jake is a freelance writer, designer, and illustrator. He currently writes articles on user experience design and web development techniques. You can check out his work on Dribbble and follow his tweets @jakerocheleau.


  1. this is useful and creative technique for me because i was finding something tricky and helping for my initial css3 skills. thanks for this great tutorial

  2. Hey Jake, this is an extremely nice and detailed tutorial.

    Just one question: You mentioned the line height of 0.5em is used to keep the original size while centering the image with the text? I’m not too sure what the line height does here as I did a quick check in Chrome dev tools… Nothing seems to change.

    Help is appreciated :)

    Oh btw, I would just like to point out that you can use icomoon app to upload or download typography fonts. That way, you can choose the fonts you want without having to load too many different things. Hope this helps!

Comments are closed.