WC3 Valid Twitter share button

If you’re like me and you want your sites to be valid and therefore have better SEO and page rankings - you must also be annoyed that the Twitter API codes for the share button, don’t validate.

Lets fix that!

Here’s the code given to you from Twitter:

<a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical"  data-via= "smith_and_sons"> Tweet </a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

So, I reworked the code to look something like this:

<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>

<a href="http://twitter.com/share?url=http%3A%2F%2Fyourwebsiteurl&amp;via=twitter_username" class="twitter-share-button" title="Click to share this post on Twitter">Tweet this Page</a>

Change the small bits of code like yourwebsiteurl and your twitter username and you get something that looks exactly the same but without the non-validating ‘data-something’ parameters. 

Here’s what you should have:

Written by Sofi

Follow me on twitter at @sofi_smith for other little things 

(Source: iamsofi.co.uk)

  1. sofismithdesign posted this