Home SEO Tools FAQs Guest post Contact Donate

Align Google +1, Tweet, Like and Pin It buttons horizontally

| 47 comments

twitter google  1 like send pinterest buttons

Update Feb. 2012: Added Pinterest Pin It button.

Even though Facebook Like & Send, Twitter Tweet and Google +1 social sharing buttons can be added easily enough by following their respective tutorials, aligning them perfectly side by side is a bit tricky. Several readers were having trouble with the alignment and contacted me for help.

Rather than attempting to explain how to align your existing buttons, I think it’s easier to just give you a new set of codes for the buttons with the alignment built in. Simply remove your existing buttons and add the new code using the following steps:

  1. Go to Design > Edit HTML  (New interface: Template > Edit HTML).
  2. Back up your template.
  3. Tick the Expand Widget Templates checkbox on top right of the code window.
  4. Next, look for <data:post.body/> tag and paste the following code immediately above it:
    <!-- Scripts Start -->
    <b:if cond='data:post.isFirstPost'>
    <!-- Facebook -->
    <div id='fb-root'/>
    <script>(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = &quot;http://connect.facebook.net/en_US/all.js#xfbml=1&quot;;
    fjs.parentNode.insertBefore(js, fjs);
    }(document, &#39;script&#39;, &#39;facebook-jssdk&#39;));
    </script>
    <!-- Google +1 -->
    <script type='text/javascript'>
    (function() {
    var po = document.createElement(&#39;script&#39;); po.type = &#39;text/javascript&#39;; po.async = true;
    po.src = &#39;https://apis.google.com/js/plusone.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(po, s);
    })();
    </script>
    <!-- Twitter -->
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=&quot;//platform.twitter.com/widgets.js&quot;;fjs.parentNode.insertBefore(js,fjs);}}(document,&quot;script&quot;,&quot;twitter-wjs&quot;);</script>
    </b:if>
    <!-- Scripts End -->
    <!-- Horizontal social buttons Start -->
    <div class='horizontal-social-buttons' style='padding:10px 0 10px;'>
    <!-- Twitter -->
    <div style='float:left;'>
    <a class='twitter-share-button' data-count='horizontal' data-lang='en' data-related='' data-via='' expr:data-text='data:post.title' expr:data-url='data:post.url' href='https://twitter.com/share'>Tweet</a>
    </div>
    <!-- Google +1 -->
    <div style='float:left;'>
    <g:plusone annotation='bubble' expr:href='data:post.url' size='medium'/>
    </div>
    <!-- Facebook Like+Send -->
    <div style='float:left;'>
    <fb:like colorscheme='light' expr:href='data:post.url' font='' layout='button_count' send='true' show_faces='false'/>
    </div>
    <!-- Pinterest Start -->
    <b:if cond='data:blog.pageType == &quot;item&quot;'>
    <div id='pin-wrapper' style='display: inline;'>
    <a class='pin-it-button' count-layout='horizontal' expr:href='&quot;http://pinterest.com/pin/create/button/?url=&quot; + data:post.url'>Pin It</a>
    <a href='javascript:void(run_pinmarklet())' style='margin-left:-93px; width:43px; height:20px; display:inline-block;'/>
    </div> 
    <script src='http://assets.pinterest.com/js/pinit.js' type='text/javascript'></script>
    <script type='text/javascript'>
    function run_pinmarklet() {
        var e=document.createElement(&#39;script&#39;);
        e.setAttribute(&#39;type&#39;,&#39;text/javascript&#39;);
        e.setAttribute(&#39;charset&#39;,&#39;UTF-8&#39;);
        e.setAttribute(&#39;src&#39;,&#39;http://assets.pinterest.com/js/pinmarklet.js?r=&#39; + Math.random()*99999999);
        document.body.appendChild(e);
    }
    </script>  
    </b:if> 
    <!-- Pinterest End -->
    </div>
    <div style='clear: both;'/>
    <!-- Horizontal social buttons End -->
    

    All buttons will appear on all pages with the exception of Pinterest Pin It button, which will appear only on post pages.

  5. Button positioning
    To position the buttons at the bottom of post, place the code below (instead of above) <data:post.body/>
  6. Preview before saving.

Enjoy!

p.s. If you wish you can also align share buttons vertically on the side of your blog.

47 comments to "Align Google +1, Tweet, Like and Pin It buttons horizontally"

zulkbo January 24, 2012 5:54 PM    

Bagaimanaa yang dah gunakan
widget dari ADD THIS tapi
tak align..boleh guna tak
tutorial ni :)

Ajaya Gajurel January 24, 2012 5:57 PM    

its better. thanks for it greenlava.

ehl-i blog January 24, 2012 7:02 PM    

how to edit codes if I want to show counter on the top of share button not right side

makko January 24, 2012 8:24 PM    

hi Good day!

First I would like to thank you for your helpful tips, I've even used your Simply Faster Template for my blog here: http://www.makkopals.com/

My question is, from the Simply Faster Template i saw 3 to where should I post your code?

shree@SOFTECHNOGEEK January 24, 2012 9:01 PM    

thanks for the share

Oliver Doetsch January 24, 2012 9:08 PM    

Works fine! Thank you

Greenlava January 24, 2012 11:47 PM    

@zulkbo
Saya tak pasti, tapi boleh cuba letak kod AddThis button spt di bawah:
[div style='float:left;']
LETAK KOD SINI
[/div]

lepas tu insert kod di atas selepas line 39.

Greenlava January 24, 2012 11:58 PM    

@ehl-i blog
To customize individual buttons, visit their respective tutorials. The links are given at the beginning of this post.

Greenlava January 25, 2012 12:07 AM    

@makko
For Simply Faster Template, you'll have to add the code at two (out of three) places. Both places are located between these comments:
< !-- multipost pages conditional -->
DO YOUR STUFF HERE
< !-- multipost pages conditional -->

Farmgirl Susan January 25, 2012 12:47 AM    

Hi Greenlava,
Thanks so much for all the helpful information you share with us! I'm wondering if there's a way to use your code but with different buttons? For example, I would love to have these buttons horizontally aligned at the top of each of my posts:

Facebook like
tweet
stumbleupon
pinterest

Thanks! :)

makko January 25, 2012 1:38 AM    

I got it working Thank You Very Much!!! you are a star and expect me to follow all your post... i am trying to learn everything from here... thanks again mate ^_^

Gerry Wendel January 25, 2012 11:48 AM    

The code that you say to place this in front of, [data:post.body/] is not found anywhere in the html for my blog. I use blogger if that helps you any.

Searched on the whole string, then tried post, then tried body. Is there something else it might say?

nicole / Twitter: BTHM1 January 25, 2012 12:16 PM    

i have stumble upon and pinterest buttons already- where do I add them in the above code?

Thanks for the help- this has been vexing me too!

makko January 25, 2012 2:57 PM    

I got it working, hope you'll not get tired sharing helpful tips... I wish you more blessings!! Thanks you Sir!

Farmgirl Susan January 26, 2012 8:52 AM    

Hi again,
I have another question. Do you take requests for post topics? :)

I've just spent several (more) hours unsuccessfully trying to add a 'pin this' Pinterest button to the top of each of my Blogger blog posts, next to the Facebook 'like' button I already have up there. The official pinterest button code (found here: http://pinterest.com/about/goodies/) apparently doesn't work for individual Blogger posts, and several other instructions and codes I found online don't work either.

I bet you could figure out how to install that pesky button - and I'm sure I'm not the only one who would be eternally grateful. Thanks for considering it - and for all the help you've already given us! :)

personalized items January 26, 2012 5:50 PM    

You're right, everybody knows how to put these buttons but never aligned properly. Thanks for the share, this is really a valuable information. I will try it right now on my blog and see if its gonna work out fine.

Gerry Wendel January 26, 2012 11:25 PM    

Wrote a comment here the other day...don't see it!

My html on blogger does not have

Is there another string I should look for?

Greenlava January 27, 2012 12:14 PM    

@Farmgirl Susan
@nicole / Twitter: BTHM1
If you notice, each button code is wrapped in a div tag, like this:
[div style='float:left;']
SHARE BUTTON CODE
[/div]

so if you want to replace a button, just replace the respective button code with the new button code.
To add a button, simply insert the new button code (wrapped with a div tag like above)right after line 39.

Greenlava January 27, 2012 12:17 PM    

@Gerry Wendel
Have you checked the Expand Widget Templates checkbox before looking for the code?

conference merchandise January 27, 2012 5:15 PM    

Hi Greenleave, I'm setting up a site right now and I got a lot of ideas on how to input buttons on one's site. Instead of reading through those articles, I'll be following this concise set of instructions you have on your article. I'ts nice of you to share brief ideas.

Farmgirl Susan January 28, 2012 12:49 AM    

Great, thanks. So in order to install a totally different button (for stumbleupon, etc.) would anything need to be changed or added in lines 1 - 24 as well?

If you want to change the facebook like/send button to just a facebook like button, would anything need to be changed in lines 1-24?

Thanks so much. :)

Becky January 28, 2012 5:17 AM    

Thanks so much for all your tips!

Just copied to put in my blog - and the Facebook icon isn't working. Twitter and Google+ are. Any thoughts?

Also - I have a floating share button that I HATE and cannot figure out how to delete it.

Spatch Merlin @ How to Blog January 28, 2012 11:26 AM    

Greenlava, thank you for this helpful information. This is very important as social media widgets are important parts of any blog.

Greenlava January 28, 2012 9:13 PM    

@Farmgirl Susan
Most button codes consist of two parts -one part is a script and the other one is a HTML.
For best result put the script part within lines 1-24 and the HTML part after line 39. The purpose is to prevent multiple script loadings on multi-post pages.
That said if you were to put the script and HTML together (as in my previous reply), that should work too.
To show Facebook Like without Send, change send='true' to send='false' (line 38).

Blog Informer January 28, 2012 11:55 PM    

Thanks for sharing this critical information with your readers. I look forward to reading more and more from your blog.

ADZA IRDAWATI aka MAK DARA January 29, 2012 10:42 PM    

Nice entry indeed..

btw i just voted for you for Worlds Bloggers And Social Media Awards 2012.. All the best ya... =)

Plsssss vote me back for THE WORST BLOG OF THE YEAR @http://socialmediaweek.com.my/awards/category.php?id=33 "click vote di link www.bicaramakdara.com ye Thank youuuu =)

Greenlava January 30, 2012 2:51 AM    

@ADZA IRDAWATI aka MAK DARA
Thanks for voting.
Voted yours.

Farmgirl Susan January 31, 2012 1:40 AM    

Thanks for the help! :)

Materi Dakwah Islam dan Kultum January 31, 2012 7:18 AM    

thanks for all your share!

Gerry Wendel February 2, 2012 3:13 AM    

Yes, it worked now...thanks!

Jouie February 2, 2012 12:54 PM    

I followed everything but I have a problem. The Facebook button is not visible along with the two other buttons. I hope you can help me on this.
Thank you in advance.
Jouie

Greenlava February 2, 2012 11:48 PM    

@Jouie
It looks fine from here.

adwy blog February 3, 2012 11:46 PM    

thanks for ur post. it worked now.

Blogspot Pemula February 5, 2012 8:01 PM    

Salam Blogger.
Situs ini banyak memberikan kontribusi ilmu yang bermanfaat buat kami.
Terimakasih

Mike February 5, 2012 8:37 PM    

The google plus logo isn't showing for me. Any help?

Prayag Verma February 9, 2012 2:22 PM    

Simple tip but very useful !!

Ryan Armbrust February 14, 2012 10:56 PM    

I would LOVE to see the pinterest button added to the 3 above. Any way to do that?

Erin Faye February 15, 2012 1:10 PM    

Hello.
I removed the google+ button and now the tweet and facebook buttons are touching eachother. How do I put a bit of space between them?

Thanks so much!

www.erinfayephotographyblog.blogspot.com

Greenlava February 17, 2012 2:00 AM    

@Erin Faye
Add a right margin to each button by replacing:
[div style='float:left;']

with this:
[div style='float:left; margin-right: 15px;']

Pierre Phil February 21, 2012 10:28 AM    

Hello. I am new to this and I need your assistance please. I have a new site. I want to deactivate the current plugin in my site and then get your horizontal look code above the post as a replacement. I'm using a wordpress blog. Where do I put the code? Thanks!

Sine February 21, 2012 5:46 PM    

@Greenlava - do you have any idea why the Google +1 button sometimes shows and sometimes doesn't? I've made some changes on my blog to reposition Linkwithin (as suggested by you) and briefly the Google +1 button actually showed, which it hadn't before, but now it's disappeared again. It's almost as if I didn't change anything in that particular code. Code it be my browser or something on the Google side? My blog: http://joburgexpat.blogspot.com. Thanks!

Harwinder February 23, 2012 1:04 AM    

the way u expressed post is just awesome!!

Tom February 23, 2012 11:15 AM    

I loaded the script onto my page and it works great. It however is a little too close to the body and looks to close. How can I add some padding to the bottom to space it out. Thanks!

Greenlava February 25, 2012 3:44 PM    

@Tom
Increase the padding in line 27:
padding:5px 0 5px;

The second "5px" is the value for the bottom padding.

Greenlava February 28, 2012 7:49 PM    

@Ryan Armbrust
Pinterest Pin It button added.

Gil Camporazo February 29, 2012 11:38 AM    

I've experimented my blog on posting social buttons like the Twitter, Facebook Like and so on 'caused I couldn't perfect it. Now I've found your simple, helpful tips which I right away adapted it in my blog. Thank you very much. I really appreciate your tips - a resourceful tips for this matter. Now they're are neatly done and orderly posted in all of my blog posts.

anncash February 29, 2012 7:11 PM    

Thanks for this, very helpful. I was able to use your codes immediately!

We love to hear from you! Leave us a comment.

If your question is unrelated to this article, please use our Facebook page.
When posting HTML/XML code, replace < and > symbols with [ and ] respectively. The reverse applies when copying code from my replies here.

Pls share this page

Get this
Click to go to top Click to comment