Your question could have done with a bit more detail!
For a start the DHTML control is deprecated and I have been using the a DIV with CONTENTEDITABLE enabled (not sure what the MS jargon for this is but it is the replacement to the DHTML editing control)
It automatically respects any styles defined in the page containing it.
var el = cursorPos.parentElement();
el.className = "strapline";
cursorPos is set by a function called on keydown and mousedown in the DIV which does:
after making sure the selection is of type 'text'. If it is type 'control' it does:
el = document.selection.createRange();
It only seems to format whole paragraphs even if you select sub-blocks. I don't know what other formats other than <p> that the execCommand("formatblock") accepts and can't find anything on MSDN...
I have also tried this:
cursorPos.className = mystyle;
I also played with something like this:
but you need to get an element into el first...