This example uses Internet Explorer ranges and will only work on Internet Explorer. <html> <head> <title>IE Range Example</title> <script type="text/javascript"> function useRanges() { var oRange = document.body.createTextRange(); var oP1 = document.getElementById("p1"); oRange.findText("Hello"); oRange.text = "Java2s.com"; } </script> </head> <body><p id="p1"><b>Hello</b> World</p> <input type="button" value="Use Ranges" onclick="useRanges()" /> </body> </html>