Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <div id="encoded"></div> <div id="decoded"></div> <script> let string1 = "Html & Css & Javascript"; let string2 = "Html & Css & Javascript"; function htmlDecode(input) { const textArea = document.createElement("textarea"); textArea.innerHTML = input; return textArea.value; } function htmlEncode(input) { const textArea = document.createElement("textarea"); textArea.innerText = input; return textArea.innerHTML.split("<br>").join("\n"); } document.getElementById("encoded").innerText = htmlEncode(string1); document.getElementById("decoded").innerText = htmlDecode(string2); </script> </body> </html>