Adblock Element Hiding
Checks for HTML elements and CSS classes that would be hidden by common adblockers, causing layout breaks or missing functionality for users with ad blocking enabled.
- Adblockers use EasyList filter rules to hide elements with class names, IDs, or patterns associated with ads
- Common blocked names: `.ad`, `.ads`, `.advertisement`, `.banner`, `#ad`, `#ads`, `#banner`, `.sponsor`
- Affected elements: legitimate banners, notification bars, promotional sections, and cookie consent notices
- Test your site with uBlock Origin enabled — check for missing content, broken layouts, or hidden consent banners
- Rename affected elements using semantic, content-specific class names to avoid false-positive blocking
Rule Details
Adblockers use filter lists such as EasyList (opens in new tab) and uBlock Origin's static syntax (opens in new tab) to identify and hide advertising elements. Those rules match against element IDs, class names, and URL patterns, so legitimate UI that uses ad-associated names can get caught as a false positive.
Code Example
Filters use CSS selector syntax:
##.advertisement # Hide elements with class "advertisement"
###ad-container # Hide element with ID "ad-container"
##[id^="ad-"] # Hide elements with ID starting with "ad-"
##[class*="banner"] # Hide elements with "banner" in class nameAny element on your page matching these selectors is hidden (set to display: none).
Why It Matters
If your cookie consent banner has class .cookie-banner or ID #consent-popup, adblockers may hide it. Because the HTML class attribute (opens in new tab) is exactly what those selectors target, users may never see the consent notice, which creates both compliance risk and broken UX.
Commonly Blocked Patterns
Class Names (Avoid These)
/* These will be hidden by most adblockers */
.ad
.ads
.ad-block
.ad-container
.advertisement
.advert
.advertising
.banner
.sponsor
.sponsored
.promotion
.promo
.cookie-banner
.cookie-notice
.gdpr-banner
.consent-banner
.tracking-noticeIDs (Avoid These)
<!-- These IDs are commonly blocked -->
<div id="ad"></div>
<div id="ads"></div>
<div id="advertisement"></div>
<div id="banner"></div>
<div id="cookie-banner"></div>
<div id="consent-popup"></div>Common False Positives
| Element | Blocked Name | Safe Rename |
|---|---|---|
| Cookie consent | .cookie-banner | .privacy-controls |
| Cookie consent | #consent-popup | #privacy-preferences |
| Promotional section | .promotion | .featured-offer |
| News ticker | .banner | .headline-ticker |
| Announcement bar | .ad-bar | .site-notice |
| Sidebar | #sidebar-ads | #sidebar-recommendations |
Cookie Consent Banner Risk
Cookie consent banners are a specific concern because adblockers block them aggressively — but GDPR requires users to see and interact with them:
❌ Likely blocked by EasyPrivacy
<div class="cookie-banner" id="gdpr-notice">
<p>We use cookies...</p>
</div>
✅ Less likely to be blocked
<div class="privacy-controls" id="privacy-preferences-dialog" role="dialog">
<p>We use cookies...</p>
</div>Testing for Adblocker Impact
Manual Testing
- Install uBlock Origin in a test browser profile
- Enable default filter lists (EasyList, EasyPrivacy, uBlock filters)
- Load your pages and inspect for:
- Missing content sections
- Broken layout (empty spaces where elements were)
- Cookie consent banner not visible
- Navigation items hidden
Browser DevTools
With uBlock Origin active, hidden elements show in DevTools with display: none applied by the extension's CSS injection.
Automated Check
// Check if a critical element was hidden by an adblocker
function isElementBlocked(selector) {
const el = document.querySelector(selector)
if (!el) return false // Element not in DOM
const style = window.getComputedStyle(el)
return style.display === 'none' || style.visibility === 'hidden'
}
// In your consent management initialization:
if (isElementBlocked('#privacy-preferences-dialog')) {
// Adblocker may have hidden the consent dialog
// Consider fallback approach
console.warn('Consent dialog may be blocked by browser extension')
}Best Practices for Naming
- Use semantic, content-describing names:
.featured-article,.site-announcement,.newsletter-signup - Avoid words associated with advertising:
ad,ads,banner,sponsor,promo,tracking - Use BEM or scoped naming to reduce collisions with filter patterns
Actual advertisements and tracking pixels should use names that adblockers can identify — this is the intended behavior. Only rename elements that serve legitimate non-advertising purposes but are accidentally caught by filters.
Exceptions
- A weaker form control is only acceptable when the business requirement and compensating controls are documented explicitly.
- If the flow is already transport-insecure, inaccessible, or externally embedded in a way that changes the threat model, fix that stronger issue first.
- False positives are common on demo, sandbox, or intentionally constrained flows, but they should still be bounded and clearly labeled.
Standards
- Align the implementation with EasyList Filter Rules and verify the effective response or browser behavior, not only the configuration file.
- Align the implementation with uBlock Origin Filter Syntax and verify the effective response or browser behavior, not only the configuration file.
- Align the implementation with MDN: HTML class attribute and verify the effective response or browser behavior, not only the configuration file.
Verification
Automated Checks
- Test the affected flow in a production-like environment, not just local development.
- Document any intentional exceptions explicitly.
Manual Checks
- Inspect the final HTTP response or browser behavior to confirm the control is actually enforced.
- Verify third-party integrations or embeds still work after the restriction is applied.
Use with AI
Copy these prompts to use with your AI assistant, or install the MCP server to use directly from Claude, Cursor, or Windsurf.
Check
Verify implementation
Review the HTML source for element IDs and class names that match common adblocker patterns: .ad, .ads, .advertisement, .banner, .sponsor, #ad, #banner, .cookie-notice, .consent. Test the page with uBlock Origin enabled in a browser to identify elements that are hidden.
Fix
Auto-fix issues
Rename affected elements using specific, content-focused class names that do not match adblocker patterns. For cookie consent banners specifically, use class names like .privacy-controls or .cookie-preferences instead of .cookie-banner or .gdpr-notice.
Explain
Learn more
Explain how adblocker filter lists work, which HTML class names and IDs are commonly blocked, and how to rename elements to avoid false-positive blocking while maintaining their function.
Review
Code review
Review server config, headers, forms, and integration points related to Adblock Element Hiding. Flag exact responses, cookies, or browser behaviors that violate the rule, and verify them against the effective production-like response.