You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
@@ -4296,6 +4297,62 @@ The `:not()` is considered as a standard CSS pseudo-class inside the argument of
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 ` `.
4303
+
4304
+
**Syntax**
4305
+
4306
+
```text
4307
+
[target]:empty-trimmed
4308
+
```
4309
+
4310
+
- `target` — optional, standard or extended CSS selector, can be skipped for checking *any* element
4311
+
4312
+
:::note
4313
+
4314
+
This pseudo-class has no arguments.
4315
+
4316
+
:::
4317
+
4318
+
:::info Compatibility
4319
+
4320
+
Added in ExtendedCSS v2.0.0.
4321
+
4322
+
Rules with the `:empty-trimmed` pseudo-class are supported by AdGuard Browser Extension v5.5 or later. Such rules do not work in AdGuard Content Blocker.
4323
+
4324
+
:::
4325
+
4326
+
**Examples**
4327
+
4328
+
`div > p:empty-trimmed` selects `p#empty`, `p#spaces`, `p#nbsp`, `p#child-empty`, and `p#comment`:
4329
+
4330
+
```html
4331
+
<!-- HTML code -->
4332
+
<div>
4333
+
<p id="empty"></p>
4334
+
<p id="spaces"></p>
4335
+
<p id="nbsp"> </p>
4336
+
<p id="text">hello</p>
4337
+
<p id="child-empty"><span></span></p>
4338
+
<p id="child-text"><span>world</span></p>
4339
+
<p id="comment"><!-- hidden --></p>
4340
+
<p id="zwsp">​</p>
4341
+
</div>
4342
+
```
4343
+
4344
+
`div > p:not(:empty-trimmed)` selects `p#text`, `p#child-text`, and `p#zwsp`.
4345
+
4346
+
:::note
4347
+
4348
+
An element like `<p><span></span></p>` matches `:empty-trimmed` (its text content is empty) but does **not** match native `:empty` (it has a child `<span>` node).
4349
+
4350
+
Elements containing only HTML comments (e.g. `<!-- hidden -->`) also match `:empty-trimmed`, because comment nodes are not reflected in`textContent`.
4351
+
4352
+
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`.
0 commit comments