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

I'd like to mention a different use case for this which seems quite compelling to me.  Consider HTML documentation of a user interface.  It might well contain documentation like:
```html
<p>After reviewing the submission, press <button>Unfreeze</button> to approve it.</p>
````
Suppose you want to increase the spacing around the button (perhaps because your CSS includes an effect like a shadow on the button), you probably want a CSS rule like this:
```css
p button { margin: 0 0.25rem }
```

However, if the button is at the start of the paragraph, this rule means it's not flush with the left margin which looks odd, e.g. in this example:
```html
<p><button>Delete</button> will <b>irreversibly</b> delete the submission.</p>
```

It would be good if we could add a rule to remove the margin in this case, though I think this needs the proposed `:first-node` pseudo-class.
```css
p button:first-node { margin: 0 }
```

In this case, you're still styling elements, not text nodes, but are doing so based on the presence or absence of an earlier (non-whitespace) node.

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


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

Received on Saturday, 18 November 2023 13:47:28 UTC