If this is for Java [and Selenium 2] then why not use Fighting Layout Bugs project?
Add the dependency and you can create a test like this:
FirefoxDriver driver = new FirefoxDriver();
try {
String testPageUrl = "http://www.test.de/";
driver.get(testPageUrl);
WebPage webPage = new WebPage(driver);
FightingLayoutBugs flb = new FightingLayoutBugs();
final Collection<LayoutBug> layoutBugs = flb.findLayoutBugsIn(webPage);
System.out.println("Found " + layoutBugs.size() + " layout bug(s).");
for (LayoutBug bug : layoutBugs) { System.out.println(bug); }
}
catch (Exception e) {
e.printStackTrace();
}
finally {
driver.quit();
}