diff --git a/docs/general/ad-filtering/create-own-filters.md b/docs/general/ad-filtering/create-own-filters.md index 1b9ba1f5cab..76df2031ae7 100644 --- a/docs/general/ad-filtering/create-own-filters.md +++ b/docs/general/ad-filtering/create-own-filters.md @@ -3565,6 +3565,7 @@ example.org#@#body{remove:true;} - [Pseudo-class `:remove()` and pseudo-property `remove`](#remove-pseudos) - [Pseudo-class `:is()`](#extended-css-is) - [Pseudo-class `:not()`](#extended-css-not) +- [Pseudo-class `:empty-trimmed`](#extended-css-empty-trimmed) - [Pseudo-class `:if-not()` (removed)](#extended-css-if-not) CSS 3.0 is not always enough to block ads. To solve this problem AdGuard extends CSS capabilities by adding support for the new pseudo-elements. We have developed a separate [open-source library](https://github.com/AdguardTeam/ExtendedCss) for non-standard element selecting and applying CSS styles with extended properties. @@ -4258,6 +4259,60 @@ The `:not()` is considered as a standard CSS pseudo-class inside the argument of ``` +#### Pseudo-class `:empty-trimmed` {#extended-css-empty-trimmed} + +The `:empty-trimmed` pseudo-class allows selecting elements without text content. Unlike the native CSS [`:empty`](https://developer.mozilla.org/en-US/docs/Web/CSS/:empty) pseudo-class, which matches elements that have no child nodes at all (no elements, no text nodes), `:empty-trimmed` checks `textContent` of the element **and its descendants**. It also matches elements whose text content consists only of whitespace, including non-breaking spaces such as ` `. + +**Syntax** + +```text +[target]:empty-trimmed +``` + +- `target` — optional, standard or extended CSS selector, can be skipped for checking *any* element + +:::note + +This pseudo-class has no arguments. + +::: + +:::info Compatibility + +Rules with the `:empty-trimmed` pseudo-class are supported by AdGuard Browser Extension. Such rules do not work in AdGuard Content Blocker. + +::: + +**Examples** + +`div > p:empty-trimmed` selects `p#empty`, `p#spaces`, `p#nbsp`, `p#child-empty`, and `p#comment`: + +```html + +
+
+
hello
++
world
+ +
+` matches `:empty-trimmed` (its text content is empty) but does **not** match native `:empty` (it has a child `` node). + +Elements containing only HTML comments (e.g. ``) also match `:empty-trimmed`, because comment nodes are not reflected in `textContent`. + +Zero-width characters such as zero-width space (`\u200B`) are **not** treated as whitespace. An element containing only zero-width characters does **not** match `:empty-trimmed`. + +::: + #### Pseudo-class `:if-not()` (removed) {#extended-css-if-not} :::danger Removal notice