AdSense for search (AFS)

Use conditional styling to apply multiple custom search styles to your search results pages

All custom search styles have a default style. This is the styling that's applied to pages that use its style ID. However, you can apply a different style instead of the default style by using conditional styling.

Conditional styling lets you apply different styling to your search results pages on different platforms and to parts of a single page. For example, you might you want to apply different styling to your ads when they appear on desktop versus mobile.

You use style rules to specify when you want a conditional style to be applied. You can create style rules for platforms (desktop, mobile, etc.) and/or ad containers. For example, let's say you have a style (mobilestyle1) that you want to apply when your ad container (afscontainer1) appears on mobile. You'd create a style rule like this: apply mobilestyle1 if platform is mobile and container ID is afscontainer1.

How to set up a conditional style

  1. Sign in to your AdSense account.
  2. Click Ads for search and then Custom search styles.
  3. Click Edit Edit next to the style that you want to apply rules to.
  4. Click the conditional styling button Conditional styles icon.
  5. In the "Conditional styling" panel, click + Add conditional style.
  6. Enter a name for your conditional style.
  7. Create a style rule by selecting a platform and (optionally) entering a container ID.
    Tip: To apply your conditional style to all containers on the page, except those that are targeted by ID in other conditional styles, leave the container ID field blank.
  8. Click Save. If you've made changes to the styling for this rule, you'll also be asked to choose a saving option.

Edit the style rule for a conditional style

  1. Sign in to your AdSense account.
  2. Click Ads for search and then Custom search styles.
  3. Click Edit Edit next to the style with the conditional style that you want to edit.
  4. Click the conditional styling button Conditional styles icon.
  5. In the 'Conditional styling' panel, find the conditional style that you want to edit.
  6. Click More More and then Edit.
  7. Make the required changes to your style rule.
  8. Click Save.
  9. Click Save to confirm.
    Note: When you update a style rule it immediately affects all search ads that use that style.

Delete a conditional style

  1. Sign in to your AdSense account.
  2. Click Ads for search and then Custom search styles.
  3. Click Edit Edit next to the style with the conditional style that you want to delete.
  4. Click the conditional styling button Conditional styles icon.
  5. In the 'Conditional styling' panel, find the conditional style that you want to delete.
  6. Click More More and then Delete.
  7. Click Delete to confirm.
    Note: When you delete a conditional style it immediately affects all search ads that use that style.
Was this helpful?
How can we improve it?

Need more help?

Sign in for additional support options to quickly solve your issue