Let’s troubleshoot this step by step.
- Where is this CSS running?
• In a regular webpage (i.e. you added it to your own styles.css)?
• As part of a browser UI tweak (e.g. Firefox’s userChrome.css)?
• Inside an Electron/CEF‐based app?
Knowing that will guide exactly how and where you can override it.
1. If you’re working on a normal web page
a) Confirm the selector matches the element’s ID.
• Open DevTools (F12) → Elements panel → find the element → make sure its id="context-setDesktopBackground" (no typos!).
b) Confirm your stylesheet is actually loading after any other CSS that might re-show it.
• In the Network tab you should see your CSS file with a 200 status.
• In the Styles pane, look for competing rules and see which one “wins.”
If it is loading and still losing to some other rule, you can beef up specificity or use an inline style:
/* even more specific */
html body #context-setDesktopBackground {
display: none !important;
}
Or, directly in markup:
<div id="context-setDesktopBackground" style="display:none!important">…</div>
2. If you’re trying to hide the “Set as Desktop Background” item in Firefox’s context menu
Firefox’s UI is built with XUL and shadow DOM, so you need to
-
Create or edit userChrome.css in your profile’s chrome/ folder.
-
Enable loading it:
– Go to about:config, set toolkit.legacyUserProfileCustomizations.stylesheets → true.
-
Paste:
/* Hide “Set as Desktop Background” in image context menu */
#context-setDesktopBackground {
display: none !important;
}
-
Save and fully restart Firefox.
3. If it’s inside an Electron/CEF app with shadow DOM
You can’t reach into a shadow root from a global stylesheet. You either:
• Inject a <style> inside the shadow root via JS, or
• Use the ::part()/::slotted() APIs if the component exposes them.
Next steps
- Tell me exactly where and how you’ve added that CSS.
- Share a screenshot or DevTools snippet showing the computed styles on that element.
With that info we can pinpoint why your rule isn’t taking effect! 😊