hide-if-svg-contains
The hide-if-svg-contains snippet hides any HTML element matching a CSS selector if it contains a SVG image with the given visible text.
Parameters
|
Name |
Description |
Mandatory |
|---|---|---|
|
search |
Text or regex pattern to match within SVG visible content. |
Yes |
|
selector |
CSS selector identifying which elements to hide. |
Yes |
|
searchSelector |
Target specific elements containing the matched text. Defaults to |
No |
Key default behaviors
The snippet automatically treats these as invisible (overridable via optional parameters):
-
Elements with
display:none -
Text with
visibility:hidden -
Content with
opacity:0 -
SVG elements with
fill:none
Example
hide-if-svg-contains Sponsored div.parent div.child — scans div.child elements and hides div.parent if the background image contains "Sponsored".