How can I escape a single quote?

How can I escape a ' (single quote) in HTML?

This is where I’m trying to use it:

<input type="text" id='abc' value="hel"lo'>

The result for the above code is “hel” populated in the text box. I tried to replace ' with \', but this what I’m getting.

<input type="text" id='abc' value="hel\"lo'>

The result for the above code is “hel” populated in the text box.

How can I successfully escape the single quotes?

9 Answers
9

Leave a Comment