Skip to main content
Question

Multiple css selectors for a badge

  • April 11, 2024
  • 3 replies
  • 46 views

We are trying to place a badge for an engagement next to an image in our header (the same image, same location). The only issue is the selector name is different in a few places.

Is there a way to use more than one selector in the field below?

 

3 replies

rschlette
Forum|alt.badge.img+2
  • Expert ⭐️
  • April 11, 2024

It is often possible to use a comma as an OR operator to solve this kind of problem, e.g. “.imageClass1,.imageClass2”

 

If that doesn’t work in this instance, you can try inspecting the two selectors for any common traits that would allow you to use other operators like ‘contains’ or ‘ends in’ to find something sufficient to work in both cases. There’s a good reference for those selectors at https://www.w3schools.com/cssref/css_selectors.php


  • Helper ⭐️⭐️
  • April 11, 2024

@rschlette 

We use a custom class to identify our targets - data-px

This requires us to define the items using

[data-px=”thing1”]

 

Would we be able to use something similar ?

like [data-px=”thing1”],[data-px=”thing2”]

or [data-px=”thing1”,data-px=”thing2”]

 


rschlette
Forum|alt.badge.img+2
  • Expert ⭐️
  • April 11, 2024

@lpicone Yes, the syntax [data-px=”thing1”],[data-px=”thing2”] will work the same way