CM6: apply CSS based on start and end position

Hi, I am trying to find a function that can take in (startPos, endPos, cssClass), where the cssClass will be applied to all text from startPos to endPos. so that I can apply highlighting as shown in the screenshot.

May I know how can I do this? I have read through the system guide and reference manual and the examples but I am still very clueless…

looks like doc.markText is the solution, but this is not in CM6, I think?

I would like to be able to click a button and the highlighting will appear up to and including the first full stop.

You’re looking for decorations. See also this example.

pressing “Ctrl-h” to show the underline.
so how can i turn off the underline?