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

I don’t know how important my use-case is, but on my website, I style `<strong>` elements differently (small caps, extra bold) if they appear before any other text in a paragraph.

<img width="776" alt="Screen Shot 2019-09-22 at 5 23 27 PM" src="https://user-images.githubusercontent.com/716405/65390294-fb572480-dd5d-11e9-98f4-1f847bbe6402.png">

Currently, I have to use JavaScript to add a CSS class to these elements, but I would use the `:first-node` selector instead if it was cross browser.

```js
// add class to paragraphs that begin with a <strong> element
for (let p of article.querySelectorAll('p')) {
  let node = p.childNodes[0];
  if (node && node.nodeName === 'STRONG') {
    p.classList.add('Issue__note');
  }
}
```


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

Received on Sunday, 22 September 2019 15:29:42 UTC