Select a varying name id of an element for a custom style?

There's a website that puts ads in iframes with ids that change on reload. They also have anti addblock:

enter image description here I want to make a custom style using an extension that hides all the elements that have an id beginning with that "adsIframe". Is there any way to select all those elements?

1 answer

  • answered 2018-01-13 17:40 BenM

    You can use the wildcard attribute selectors in CSS. For example:

    iframe[id^="adsIframe"] {
       color: red;
    }
    

    Will select any iframe element whose id attribute begins with adsIframe. Using *= will target those whose id attribute contains adsIframe.

    From MSDN:

    [attr^=value]
    Represents an element with an attribute name of attr whose value is prefixed (preceded) by value.