Highlight selected text in bold:
document.execCommand('bold', null, null);
When the user selects this piece of text (or part of it) again, how can you know that it was highlighted in bold?
Bold is just an example. commandName can be underline , heading , createLink , ...
source share