To clear the selection in HTML, you can use the following code: document.getElementById("myText").