The space in the Adblock rule youtube.com##.ytp-quality-menu **.ytp-menuitem**:has(...) acts as a CSS descendant combinator. Here's what it does:
What the Space Means
- The space between
.ytp-quality-menu and .ytp-menuitem means:
"Target elements with the class .ytp-menuitem that are descendants (children, grandchildren, etc.) of an element with the class .ytp-quality-menu."
Breaking Down the Selector
-
.ytp-quality-menu:
This is the parent container (YouTube's video quality menu).
-
Space ( ):
This specifies that the next selector (.ytp-menuitem) must be nested inside the .ytp-quality-menu element.
-
.ytp-menuitem:has(.ytp-premium-label):
This targets menu items (ytp-menuitem) that contain a child element with the class ytp-premium-label.
Why the Space Matters
Example HTML Structure
Here’s how the YouTube quality menu might be structured in HTML:
<!-- Parent container (quality menu) -->
<div class="ytp-quality-menu">
<!-- Child menu items -->
<div class="ytp-menuitem">1080p</div>
<div class="ytp-menuitem">
2160p
<span class="ytp-premium-label">Premium</span> <!-- This item has the "Premium" label -->
</div>
<div class="ytp-menuitem">720p</div>
</div>
The rule:
.ytp-quality-menu .ytp-menuitem:has(.ytp-premium-label)
targets the 2160p menu item (with the "Premium" label) only if it is inside the .ytp-quality-menu container.
Key Takeaway
- The space ensures the rule scopes the
.ytp-menuitem elements to only those inside the .ytp-quality-menu.
- This prevents accidentally hiding other
.ytp-menuitem elements elsewhere on the page (e.g., in unrelated menus).
Let me know if you'd like more examples! 😊