How to select deleted or written text

How to select deleted or written text

I want to tag deleted or inserted strings like

"Hi guys"                  //original
"Hi <d>guys</d>"                 //final

in this example user tries to delete "guys" but it is just tagged. Or lets say that user adds some text to ours.

"Hi guys"                  //original
"Hi guys<i> how are you</i>"                 //final

i also want it to be tagged like that. Is there any single way, any single possibility that i can do this.