Re: [csswg-drafts] [css-highlight-api] Use marker nodes to declaratively annotate highlights (#13381)

> Is it workable?

Splitting text nodes under the same element should be fine.

Another thing I thought of though is that imperative Highlight API allows this sort of thing to be easily created:
```html
<div>
I <!-- start -- name="grammar-error" -->can <!-- start -- name="spelling-error" -->haz <!-- end name="grammar-error"-->cheezburger<!-- end name="spelling-error"-->?
</div>
```
Are overlapping markers like that allowed? If not, the declarative version might still be useful, but would be a subset of what the imperative version could do.

Or I guess it could be allowed by doing the same sort of thing with markers that the HTML parser does when it encounters stuff like 
```html
<div>
  I <b>can <i>haz </b>cheezburger</i>?
</div>
```
Which causes the `<i>` tag to be split in the parsed result:

```html
<div>
  I <b>can <i>haz </i></b><i>cheezburger</i>?
</div>
```

> We might need a new type of AbstractRange, as those ranges are not exactly live ranges.
Can it be StaticRange?
> > Probably not because the DOM might change in a way where more markers with that name are added.

With imperative highlights it's possible to have multiple highlights given by `StaticRange`s grouped under the same highlight name: https://codepen.io/daniec/pen/xbOLGpe. Seems like it's OK if the same thing were allowed declaratively? (Sorry if I'm not understanding the issue you're getting at).

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


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

Received on Thursday, 22 January 2026 21:33:23 UTC