Re: [csswg-drafts] [css-pseudo-4] `::nth-letter` pseudo-element (#3208)

>  As for ::nth-letter, I am not aware of any substitute, but neither am I aware of strong use cases.

A common use case for nth-letter/ nth-word / etc. are code or more general text editors and annotations for grammar, syntax, spelling, entities (NLP), etc. Which often require overlapping markup (see standoff properties / annotations for more). 

In above use cases styling the characters is insufficient: You will also want to register event listener, arbitrary data, … on it. So I’m not convinced an extension of the CSS spec would be a good idea.

Except for using canvas/ CSS Houdini, I currently don’t see a good alternative to using a million span tags that wrap each character. To keep the markup readable I'm storing the plain text string in a data attribute of e.g. a paragraph tag. _(however markup readability shouldn’t be a concern if you can inspect a readable JSON of the content)_
```html 
<p aria-description="Hello World">
  <span annotations={...}>H</span>
  <span annotations={...}>e</span>
  <span annotations={...}>l</span>
  <span annotations={...}>l</span>
  <span annotations={...}>o</span>
...
</p>
```


![standoff markup and annotations](https://user-images.githubusercontent.com/9489658/173823343-82ecfc98-0fbf-4857-9968-eeae97e2637d.png)



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


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

Received on Wednesday, 15 June 2022 12:14:21 UTC