Sharethis WordPress Plugin – Invalid XHTML

  • Posted February 21, 2011. Last modified February 21, 2011 by

Building on my previous post regarding invalid XHTML (Version 1.0 Strict), I have been trying to find out why my site has not been validating. It turns out, the last bit of the problem is the “Sharethis” plugin for WordPress. In this plugin, the authors decided to define some custom parameter fields within the ‘span’ tag causing the validation problems. A post here indicates it is for “simplicity” for their less technically inclined users. So, this post is to show you how to modify the plugin to get valid XHTML out of it instead.

In the sharethis.php file, the offending lines are here:


And here are the updated lines:


In this case, disabling the extra fields means that the “sharethis” text and some minor styling disappear from the sharethis button. It seems the easiest way to have compliant XHTML and still a decent looking sharethis button is to use the a custom button style (see this page).

So the result is this:


The ‘ShareThis’ text is enclosed in an “a” tag so that we get the mouseover behaviour and link styling that it had previously. Additionally, the css file for your template must be changed. This is what I added to mine to make it work:

.st_sharethis_custom { background: url("img/sharethis.png") no-repeat scroll left top transparent; padding-left: 18px; padding-top:3px;}

You will want to change the url to wherever you have located the sharethis icon, and the padding and margins may need to be adjusted for your own template.

2 comments on “Sharethis WordPress Plugin – Invalid XHTML”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.