Re: [csswg-drafts] [css-selectors] Standardize `:(‑moz‑)first‑node` and `:(‑moz‑)last‑node` (#3216)

was about to file a naive new issue, but seems some discussion on similar topic already happened here. for context, I have some styles to give `<code>` elements a specific appearance with a border around them when they're inline with other text, but want to suppress them when they're the only content inside a table cell. my original selectors were along the lines of:

```css
p > code, div > code, li > code, dd > code, td > code:not(:only-child) { ... }
```

this works for the most part, except when the `<td>` also contains some text nodes, a la

```html
...
<td>something something <code>blah</code> something</td>
...
```

the above selector still applies, as `:only-child` doesn't care about text nodes. is there some way out of this in pure CSS, or does it involve wrapping things specifically in some other container inside the `<td>` when i do still want the the styles to apply, like ...

```html
<td><p>something something <code>blah</code> something</p></td>
```

-- 
GitHub Notification of comment by patrickhlauke
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3216#issuecomment-3422773473 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 20 October 2025 16:11:29 UTC