Jump to content
View in the app

A better way to browse. Learn more.

Learn more

Different Advertisements For Light and Dark Modes

Featured Replies

I see in v5 there can be different site logos used for light and dark modes. Using code like --set__logo-light, ipsLogo__image--light, and data-ips-prefers-color-scheme="light".

Question: Is it possible to use any of the existing classes or selectors in our own custom HTML for advertisements that would enable a banner to be shown based on light or dark theme? For example, if theme=dark, show banner A, else show banner B. Or, is there another way to do this?

Edited by Chris027

Solved by Ehren

  • Author

Or, can we get a toggle like this to supply different code for different modes?

Screenshot 2026-05-17 at 6.47.33 PM.png

Using the class ipsLogo__image--light technically works, but not really. If the advertisement is selected to show, but the person is using dark mode, then no image shows.

Perhaps there is better html code I can write, with an if ipsLogo__image--light then image Z, if ipsLogo__image--dark then image B.

  • Author

OK, I think I figured out a way to do it, but unsure if it's the best.

<a href="LINK_HERE">

<!-- Light mode image (hidden in dark mode) -->

<img class="ipsLogo__image--light" src="PATH_TO_YOUR_DARK_IMAGE" alt="light-image">

<!-- Dark mode image (hidden in light mode) -->

<img class="ipsLogo__image--dark" src="PATH_TO_YOUR_DARK_IMAGE" alt="dark-image">

</a>

  • Community Expert
  • Solution

Those classes should only be used for the logo. Use this instead:

<a href="LINK_HERE">
	<!-- Light mode image (hidden in dark mode) -->
	<img class="i-display_light" src="PATH_TO_YOUR_LIGHT_IMAGE" alt="light-image" loading="lazy">
	<!-- Dark mode image (hidden in light mode) -->
	<img class="i-display_dark" src="PATH_TO_YOUR_DARK_IMAGE" alt="dark-image" loading="lazy">
</a>

  • Author
19 minutes ago, Ehren said:

Those classes should only be used for the logo. Use this instead:

<a href="LINK_HERE">
	<!-- Light mode image (hidden in dark mode) -->
	<img class="i-display_light" src="PATH_TO_YOUR_LIGHT_IMAGE" alt="light-image" loading="lazy">
	<!-- Dark mode image (hidden in light mode) -->
	<img class="i-display_dark" src="PATH_TO_YOUR_DARK_IMAGE" alt="dark-image" loading="lazy">
</a>

Thanks @Ehren !

Recently Browsing 0

  • No registered users viewing this page.

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.