Help others
saving time too!

How to detect high-contrasting 1px borders around ads?

Written by Roy
May 18, 2022 • 3 min read

Most self-respected publishers require ads to have clear contrasting borders. They are usually in black or gray and 1 pixel in width.

In this article I'll explain why such a border is required and how you can detect it automatically.

Why should creatives have borders?

TL;DR: because it should be unambiguous the image is an ad. Let's imagine you have a website with a color pallet that is mostly red. You may have a complete sidebar in that color. Now consider this ad:

Creative without 1px border
The ad will 'dissolve' in the red background of the sidebar, and it could be hard to distinguish where the ad starts and ends. Is it part of the web page? Is it a button?

Ads with clear borders around the image won't have this problem:

Creative with contrasting 1px border
If you're an HTML5 designer, you can simply add a 1 pixel border in Google Web Designer. See here for instructions.

How to automatically detect borders?

You can manually review the creative and check if it has a border. But wouldn't it be great to automate the whole process? You can use the APIs from to automatically detect if an ad has a high-contrasting border.

Here's how to do that using PHP.

First, download this PHP class from Github:

Then, run these lines of code:

$AdValify = new AdValify();
$array = $AdValify->scanTag("This is an ad tag...");
$has_border = $array['has_border']; //boolean

Once you have that boolean variable, you can use it further down in your logic. For example, prevent the ad from being activated and flag it for manual review. Check out the complete API Documentation for a list of all data points collected by the scanner.

Integrate AdValify's APIs into your product

APIs are fast, scalable and allows you to automate the whole creative quality assurance process. You can litterally scan thousands of ads and list if they have contrasting borders to make sure they comply with your policy.

Scan ads online to detect creative borders

No time to set up the API? Use this free online ad tag tester to scan ads. It will give you lots of information, like CPU usage, cookies dropped, load size and border detection. Great time-saver!

Free Ad Tag Tester Online


Verifying each ad or creative has a clear contrasting border can be time-consuming. Online scanners make your life a bit easier by analyzing the ad in seconds. If you want to take it a step further, APIs are a powerful tool to automate and scale detection borders around ads.

External Resources

More from